设置圆角
layer.cornerRadius
对应ValueType
为Number
或者String
,可以在Storyboard
里面进行直接设置
如果Value
值为正方形width
的一半,则为圆形
如果需要单个或者多个圆角
左上:UIRectCornerTopLeft左下:UIRectCornerBottomLeft右上:UIRectCornerTopRight右下:UIRectCornerBottomRightUIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(8, 8)];CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];maskLayer.frame = button.bounds;maskLayer.path = maskPath.CGPath;button.layer.mask = maskLayer;
边框颜色,边框宽度
设置边框宽度:layer.borderWidth
对应ValueType
为Number
或者String
设置边框颜色:layer.borderColor
对应ValueType
为Color
self.deleteButton.layer.cornerRadius = 15;//设置圆角//颜色只能代码实现,因为Storyboard不支持CGColor属性,只有UIColorself.deleteButton.layer.borderColor = [UIColor redColor].CGColor;//设置边框颜色self.deleteButton.layer.borderWidth = 0.5;//设置边框宽度
如果觉得《IOS开发之UI进阶(设置圆角 边框颜色 边框宽度)》对你有帮助,请点赞、收藏,并留下你的观点哦!