UIButton

给UIButton设置边框
1
2
3
4
5
6
7
8
9
10
btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//圆角弧度
[btn.layer setCornerRadius:5.0];
//允许修饰边框
[btn.layer setMasksToBounds:YES];
//边框宽度
[self.btn.layer setBorderWidth:1.0];
//边框颜色
[self.btn.layer setBorderColor:[UIColor greenColor].CGColor];
setMasksToBounds文档说明:

When true an implicit mask matching the layer bounds is applied to the layer (including the effects of the cornerRadius property). If both mask and `masksToBounds’ are non-nil the two masks are multiplied to get the actual mask values. Defaults to NO. Animatable.