失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > ios view添加上边框_ios – UIView的圆顶角 并添加边框

ios view添加上边框_ios – UIView的圆顶角 并添加边框

时间:2023-05-26 07:26:05

相关推荐

ios view添加上边框_ios – UIView的圆顶角 并添加边框

掩模层不被绘制,仅用于计算掩模.尝试:

-(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 view添加上边框_ios – UIView的圆顶角 并添加边框》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。