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;
相关推荐
ii_best1 小时前
按键精灵安卓/iOS脚本辅助,OpenCV实现自动化高效率工具
ios·自动化·编辑器·安卓
蒲公英少年带我飞1 小时前
iOS底层原理:Method Swizzling原理和注意事项
ios
蒲公英少年带我飞1 小时前
iOS底层原理:KVC分析
ios
2501_915921432 小时前
iOS混淆与IPA加固全流程(iOS混淆 IPA加固 Ipa Guard实战)
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者82 小时前
iOS 26 App 开发阶段性能优化 从多工具协作到数据驱动的实战体系
android·ios·小程序·uni-app·iphone·webview·1024程序员节
2501_915106322 小时前
深入剖析 iOS 26 系统流畅度,多工具协同监控与性能优化实践
android·ios·性能优化·小程序·uni-app·cocoa·iphone
蒲公英少年带我飞2 小时前
iOS底层原理:OC对象底层探索之alloc初探
ios
Digitally3 小时前
如何准备 iPhone 以旧换新:10 个重要提示
ios·iphone
Tlaster5 小时前
使用KMP实现原生UI + Compose混合的社交客户端
android·ios·开源
游戏开发爱好者85 小时前
iOS 26 App 查看电池寿命技巧,多工具组合实践指南
android·macos·ios·小程序·uni-app·cocoa·iphone