如何裁剪UIImage有圆角

时间:2014-07-25 11:48:18

标签: ios objective-c uiimageview uiimage

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

enter image description here

你能帮助我吗?

2 个答案:

答案 0 :(得分:8)

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是我的自定义表格视图。

答案 1 :(得分:-1)

这样做的简单方法

 ImageView.layer.cornerRadius  = 10.0f;
    ImageView.layer.borderWidth = 1.0f;
    ImageView.layer.borderColor = [[UIColor  whiteColor] CGColor];

用相同的背景颜色覆盖左侧。然后它会出现像右上角和右下角的角落