iOS 开发总结(1)--UIView圆角设置
来源:互联网 发布:知乎和天涯的区别 编辑:程序博客网 时间:2024/06/10 22:06
首先new一个view:
UIView *view = [[UIViewalloc] initWithFrame:CGRectMake(100,80, 80, 80)];
view.backgroundColor = [UIColorgreenColor];
[self.viewaddSubview:view];
1. 设置4个角全为圆角:
view.layer.cornerRadius = 5.0f;
2.设置view的下面两个角为圆角:
UIBezierPath *maskPath = [UIBezierPathbezierPathWithRoundedRect:view.boundsbyRoundingCorners:UIRectCornerBottomLeft |UIRectCornerBottomRight cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer = [[CAShapeLayeralloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
3.总结:
UIRectCorner 类型如下所示:
typedefNS_OPTIONS(NSUInteger, UIRectCorner) {
UIRectCornerTopLeft =1 << 0,
UIRectCornerTopRight =1 << 1,
UIRectCornerBottomLeft = 1 << 2,
UIRectCornerBottomRight = 1 << 3,
UIRectCornerAllCorners = ~0UL
};
使用UIBezierPath通过" | "操作组合来实现设置需要的角为圆角即可
byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
- iOS 开发总结(1)--UIView圆角设置
- iOS UIView开发总结
- ios开发——给uiview等设置圆角
- iPhone/iOS UIView开发总结
- IOS开发之UIView总结
- iPhone/iOS UIView开发总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- IOS开发之UIView总结
- iOS中UIView半边圆角设置
- iOS 给UIView设置任意圆角
- iOS开发之设置UIView边框颜色及边线厚度以及圆角及弧度
- iOS开发之UIView的一些总结
- 读取xml
- PRCR-1079 : 无法启动资源 ora.orcl.db ORA-03113: end-of-file on communication channel
- pre标签自动换行方案中遇到的一些问题
- 介绍MVP Model-View-Presenter在Android中的应用
- 在 VS2013 以 Code First 方式建立 EF 資料庫
- iOS 开发总结(1)--UIView圆角设置
- 恢复微信通讯录的方法有哪些
- 安徽六安金安区附近发生3.2级左右地震
- C# 枚举在Unity 中的使用
- LeetCode Binary Tree Right Side View
- 对大型矩阵输出到终端和txt文档的方法
- Python退格键出现方块
- 花生壳动态域名不在线怎么办
- 数据分区存放到文件中