设置UIButton一侧圆角

2017-10-27  本文已影响0人  林间aiq小道

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;

上一篇下一篇

猜你喜欢

热点阅读