1.加圓角
view.layer.cornerRadius = 8;
view.layer.masksToBounds = YES;
2.加單個圓角
UIBezierPath*path = [UIBezierPath bezierPathWithRoundedRect:sayWorldButton.bounds byRoundingCorners:UIRectCornerBottomLeft/*具體哪個角*/ cornerRadii:CGSizeMake(5,5)];
CAShapeLayer*la = [[CAShapeLayer alloc] init];
la.frame = <#要加圓角的控件#>.bounds;
la.path= path.CGPath;
<#要加圓角的控件#>.layer.mask = la;
3.加陰影
scanButton.layer.shadowColor= [UIColorblackColor].CGColor;//陰影的顏色
scanButton.layer.shadowOffset=CGSizeMake(1,1);//陰影的偏移量配合shadowRadius達到幾條邊有陰影的效果
scanButton.layer.shadowOpacity=0.5;//透明度
scanButton.layer.shadowRadius=1;//陰影大小
想要同是設(shè)置圓角和陰影
scanButton.layer.masksToBounds = YES;這個屬性要去掉
4.加邊框
view.layer.borderWidth = 5;
view.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];