ios - 如何将图像裁剪成圆角

标签 ios objective-c uiimageview uiimage

<分区>

我有一个要求,我需要用指定的半径裁剪 UIImage 的右上角和右下角。最终输出应如下图的 coreners 所示

enter image description here

谁能帮帮我吗?

最佳答案

UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:_backgroundImageView.bounds byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight)cornerRadii:CGSizeMake(5.0, 5.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
_backgroundImageView.layer.mask = maskLayer;

self 是我的自定义表格 View 单元格。

关于ios - 如何将图像裁剪成圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24955085/

上一篇:iOS:特定 View Controller 类的 didReceiveRemoteNotification

下一篇:iOS:导航栏中的 UIActivityIndi​​cator 没有停止

相关文章:

java - 如何将 .wav 文件转换为 Base64 编码字符串?

ios - 我在 Xcode7 上遇到字符串错误

iOS 8.3 共享扩展 - 启动 URL 方案

objective-c - 在内存中保存一个 c 数组,以便以后可以使用指针访问它

ios - 我应该为 LaunchScreen.storyboard 中的图像提供什么尺寸的 @3x、@2x 等?

ios - 为 iOS 应用程序实现锁屏

ios - iOS 机器人上的 Telegram 错误发送多次相同的消息

iphone - 将@property 和@synthesize 与ivar 隐式创建结合使用

swift - 限制边距在 Xcode 上无法正常工作

ios - 在 iOS7 上拍照时,有没有办法使用代码让它不水平翻转?