This question already has answers here:
Rounded UIView using CALayers - only some corners - How?
                                
                                    (14个回答)
                                
                        
                                5年前关闭。
            
                    
我有一个要求,我需要使用指定的半径裁剪UIImage的右上角和右下角。最终输出应类似于下图的核心

 

有人可以帮我吗?

最佳答案

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是我的“定制”表视图Cell。

关于ios - 如何裁剪UIImage使其具有圆角挖角器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24955085/

10-09 13:36