这是代码
- (voID) roundtopCorners:(CGfloat) radius{ self.layer.masksToBounds = YES; CGRect bounds = self.bounds; UIBezIErPath *maskPath = [UIBezIErPath bezIErPathWithRoundedRect:bounds byRoundingCorners:(UIRectCornertopleft | UIRectCornertopRight) cornerRadii:CGSizeMake(radius,radius)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = bounds; maskLayer.path = maskPath.CGPath; maskLayer.strokecolor = [UIcolor redcolor].CGcolor; self.layer.mask = maskLayer;}解决方法 掩模层不被绘制,仅用于计算掩模.尝试:
-(voID)roundCorners:(UIRectCorner)corners radius:(CGfloat)radius{ CGRect bounds = self.bounds; UIBezIErPath *maskPath = [UIBezIErPath bezIErPathWithRoundedRect:bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius,radius)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = bounds; maskLayer.path = maskPath.CGPath; self.layer.mask = maskLayer; CAShapeLayer* frameLayer = [CAShapeLayer layer]; frameLayer.frame = bounds; frameLayer.path = maskPath.CGPath; frameLayer.strokecolor = [UIcolor redcolor].CGcolor; frameLayer.fillcolor = nil; [self.layer addSublayer:frameLayer];}-(voID)roundtopCornersRadius:(CGfloat)radius{ [self roundCorners:(UIRectCornertopleft|UIRectCornertopRight) radius:radius];}-(voID)roundBottomCornersRadius:(CGfloat)radius{ [self roundCorners:(UIRectCornerBottomleft|UIRectCornerBottomright) radius:radius];}
您当前看到的框架是UITextFIEld的正常框架,因此将框架样式设置为none.您还必须调整插图来弥补将框架样式设置为无,通常没有插入的事实.
总结以上是内存溢出为你收集整理的ios – UIView的圆顶角,并添加边框全部内容,希望文章能够帮你解决ios – UIView的圆顶角,并添加边框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)