美文网首页iOS
设置UIButton一侧圆角

设置UIButton一侧圆角

作者: 我要的七秒记忆 | 来源:发表于2016-05-09 16:11 被阅读1507次

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;
B96B5DA4-8C56-4A85-9E7B-5AD3E5364C1C.png

相关文章

网友评论

    本文标题:设置UIButton一侧圆角

    本文链接:https://www.haomeiwen.com/subject/alserttx.html