设置UIButton一侧圆角

UIButton * button =[UIButton buttonWithType:UIButtonTypeSystem];
[self.view addSubview:button];//一定要先添加到视图上
button.frame=CGRectMake(100, 100, 100, 40);
button.backgroundColor=[UIColor blueColor];

UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerTopRight|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer=[[CAShapeLayer alloc]init];
maskLayer.frame=button.bounds;
maskLayer.path=maskPath.CGPath;
button.layer.mask=maskLayer;
posted @ 2017-03-09 17:31  仲长可倾  阅读(2001)  评论(0编辑  收藏  举报