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;
相关推荐
2501_9159184110 小时前
iOS 应用上架全流程实践,从开发内测到正式发布的多工具组合方案
android·ios·小程序·https·uni-app·iphone·webview
笔沫拾光10 小时前
iOS 正式包签名指南
flutter·ios·ios签名
大熊猫侯佩1 天前
「内力探查术」:用 Instruments 勘破 SwiftUI 卡顿迷局
swiftui·debug·xcode
Magnetic_h1 天前
【iOS】锁的原理
笔记·学习·macos·ios·objective-c·cocoa·xcode
Digitally1 天前
将 iPhone 联系人转移到 Infinix 的完整指南
ios·cocoa·iphone
imLix2 天前
RunLoop 实现原理
前端·ios
归辞...2 天前
「iOS」————设计架构
ios·架构
i紸定i2 天前
解决html-to-image在 ios 上dom里面的图片不显示出来
前端·ios·vue·html·html-to-image
YungFan3 天前
iOS26适配指南之UIButton
ios·swift
红橙Darren3 天前
手写操作系统 - 编译链接与运行
android·ios·客户端