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;
相关推荐
cypking2 小时前
Objective-C 语法完整学习手册(小白自学 + 开发备查)
c语言·开发语言·学习·objective-c
软泡芙17 小时前
【IOS】Codable
ios·ssh·cocoa
nvvas18 小时前
9月苹果发布会前瞻:新iPhone、Apple Watch重点速览
ios·iphone
Zender Han19 小时前
Flutter 自适应(Adaptive)与响应式(Responsive)设计实践:官方推荐方案详解
android·flutter·ios
冯汉栩20 小时前
Swift Control DateSelection(日期选择框)
ios·cocoa·swift
开心就好20251 天前
appuploader-cli 使用教程:在 Windows 上用命令行把 IPA 上传到 App Store
后端·ios
软泡芙1 天前
【IOS】CoreBluetooth
ios
冯汉栩1 天前
Swift Control DashLineView(虚线)
开发语言·ios·swift
Codeking__1 天前
iOS 动画:core Animation 底层原理
macos·objective-c·cocoa
2501_915918411 天前
iOS 真机调试工具推荐,安装运行、性能分析有哪些工具
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程