iOS-指定视图的圆角个数
来源:互联网 发布:水晶机巧矩阵黄晶 编辑:程序博客网 时间:2024/05/19 15:24
平常设置视图的圆角最普遍的就是设置四个角的,方法也就是一句代码解决:
view.layer.cornerRadius = 10;
四个圆角
但有时需求会是指定某个,或者特定哪几个角设置圆角,所以我们需要不一样的解决方法:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 150, 60, 60)];
view.backgroundColor = [UIColor orangeColor];
// UIRectCornerTopLeft 左上角 // UIRectCornerTopRight 右上角 // UIRectCornerBottomLeft 左下角 // UIRectCornerBottomRight 右下角 // UIRectCornerAllCorners 四个角 // byRoundingCorners: 参数可以选择上面五种,需要制定某几个角为圆角,就要用 “|” 组合 // cornerRadii: 代表圆角值大小
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
[self.view addSubview:view];
左上和右下
此方法可以适用很多种视图,比如UIView
、UILabel
、UIImageView
、UIButton
等。
原文链接:http://www.jianshu.com/p/3f1a38c42b2e
0 0
- iOS-指定视图的圆角个数
- ios 指定视图的圆角个数
- 指定视图的圆角个数
- iOS指定视图圆角位置
- iOS 指定视图的圆角、label、button圆角设置
- iOS - 视图圆角
- iOS 设置视图的圆角效果
- IOS使用视图控制器和视图(四)使用UISlider 实现指定范围值的选择
- 指定字符个数的strncat
- iOS中视图控制器指定自定义UIView
- 删除指定的子视图
- ios 指定角度圆角
- ios开发中常用的截取指定区域的视图转换成图片
- 关于iOS中UIView类视图的圆角
- iOS中在指定视图内进行代码截屏操作,并返回特定的图片
- [iOS] 指定UIView的某几个角为圆角
- iOS给控件的指定位置设置圆角
- IOS UIVIiew 指定一个方向的圆角处理
- [LeetCode]155. Min Stack
- Material Design创建列表与卡片
- 机房收费系统之(实时错误‘-2147217900(80040e14)')
- poi导出execl
- 笔记整理之设计模式 I
- iOS-指定视图的圆角个数
- 从使用到原理学习Java线程池 (转载)
- hdu 1026 Ignatius and the Princess I (bfs)
- Glide在RecyclerView自适应图片尺寸
- java内存管理(二)
- openstack 练习记录
- Mongodb存储特性
- C/C++中部分常见数学函数
- ELF解析