最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS 设置按钮圆角(4个角都可随意设置)
时间:2016-09-19 编辑:简简单单 来源:一聚教程网
设置按钮的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;
效果图:
-
下一个: iOS 判断字符串是否包含空格
相关文章
- 网易mumu模拟器怎么设置手柄按键 07-27
- wps表格首行缩进怎么设置 07-19
- wps电子表格怎么设置表头 07-19
- PPT怎么设置动画播放速度 07-17
- word正文格式怎么设置 07-17
- 滴滴顺风车app如何设置出行路线 07-10