最新下载
热门教程
- 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;
效果图:

相关文章
- 将魂师怎么获得b级神君 b级神君获取及培育方法攻略 12-16
- poki小游戏入口在哪里精准直达-poki小游戏入口在哪里一键速查入口 12-16
- 逆战未来磐石机甲如何使用 12-16
- 漫蛙网页版免费入口分享 manwa漫画免费阅读页面 12-16
- 巨神军师甄姬怎么组队 12-16
- 蛙漫画官方页面免费漫画观看与下载入口-蛙漫画官方正版免费资源 12-16