最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS 设置按钮圆角(4个角都可随意设置)
时间:2022-06-25 23:33:12 编辑:袖梨 来源:一聚教程网
设置按钮的4个角:
左上:UIRectCornerTopLeft
左下:UIRectCornerBottomLeft
右上:UIRectCornerTopRight
右下:UIRectCornerBottomRight
例子代码:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 60, 80, 40)];
button.backgroundColor = [UIColor orangeColor];
[self.view addSubview:button];
//这里设置的是左上和左下角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(8, 8)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = button.bounds;
maskLayer.path = maskPath.CGPath;
button.layer.mask = maskLayer;
效果图:

相关文章
- 明日方舟终末地能量淤积点消除方法 07-06
- 2025年炒币平台app哪个好?国内最新炒币软件APP排行榜一览 07-06
- 燕云十六声到此一坐成就达成方法 07-06
- 鬼谷八荒器灵法宝搭配选择推荐 07-06
- jsp实现局部刷新页面、异步加载页面的方法 07-06
- ps双下巴怎么快速消除? ps照片精修去双下巴的技巧 07-06