博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
控件的局部圆角问题
阅读量:4356 次
发布时间:2019-06-07

本文共 543 字,大约阅读时间需要 1 分钟。

 

一个button或者label,只要右边的两个角圆角,或者只要一个圆角。该怎么办呢?这就需要图层蒙版来帮助我们了

 

CGRect rect = CGRectMake(0, 0, 100, 50);

CGSize radio = CGSizeMake(5, 5);//圆角尺寸

UIRectCorner corner = UIRectCornerTopLeft|UIRectCornerTopRight;//这只圆角位置

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corner cornerRadii:radio];

CAShapeLayer *masklayer = [[CAShapeLayer alloc]init];//创建shapelayer

masklayer.frame = button.bounds;

masklayer.path = path.CGPath;//设置路径

button.layer.mask = masklayer;

 

 

 

转载于:https://www.cnblogs.com/qinxiaoguang/p/5756635.html

你可能感兴趣的文章
(原创) cocos2d-x 3.0+ lua 学习和工作(4) : 公共函数(3): 深度克隆clone()
查看>>
为什么写作
查看>>
整数子数组求最大和添加验证
查看>>
使用kubeadm安装Kubernetes
查看>>
Principal Component Analysis 主元分析
查看>>
linux分割字符串操作
查看>>
PHP学习2
查看>>
多实例Mysql配置
查看>>
linux下安装Mongodb
查看>>
Page.RegisterStartupScript和Response.Write的区别。
查看>>
hdu4348区间更新的主席树+标记永久化
查看>>
ZOJ 2532 Internship
查看>>
HDU 3452 Bonsai
查看>>
[Erlang12] Mnesia分布式应用
查看>>
图的遍历 | 1013 连通块块数
查看>>
Kinect 开发 —— 进阶指引(上)
查看>>
python学习笔记(六)time、datetime、hashlib模块
查看>>
uva489(需要考虑周全)
查看>>
C-关键字(二)
查看>>
排序笔记
查看>>