iOS-设置指定边圆角(左上、左下等)

以UILabel举例,效果图如下:

代码如下:

复制代码
//设置左上与右下圆角(可自行编辑指定圆角位置)
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_sleepStateLabel.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _sleepStateLabel.bounds;
maskLayer.path = maskPath.CGPath;
_sleepStateLabel.layer.mask  = maskLayer;
相关推荐
1024小神8 小时前
在swiftui中使用实现类似微信右上角的功能菜单
ios
北京自在科技9 小时前
iOS 18.4修复多个核心安全漏洞,间接增强Find My服务的数据保护能力
科技·ios·iphone·蓝牙·find my·北京自在科技
货拉拉技术13 小时前
iOS货运用户App组件路由器设计与实践
ios·架构
布多13 小时前
iOS分类中的关联对象:如何用运行时突破Category的存储限制
ios·面试·源码
鸿蒙布道师1 天前
鸿蒙NEXT开发数值工具类(TS)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
程序员老刘1 天前
谨慎升级macOS 15.4,规避 ITMS-90048 错误
flutter·macos·ios
90后的晨仔1 天前
iOS 蓝牙开发基础知识梳理
ios
一牛1 天前
Metal 进阶:读取可绘制对象的像素
ios·swift·计算机图形学
90后的晨仔1 天前
什么是WebSocket ?ios 中如何使用?
ios
鸿蒙布道师1 天前
鸿蒙NEXT开发日期工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei