Reputation: 13
How would I set a radius for only the bottom two corners, like in the image above?
Upvotes: 0
Views: 111
Reputation: 13281
It's been literally MONTHS since the last time I've wrote an Objective-c code, since I want to tray it again, here's the Objective-c version of Mago Nicolas Palacios' answer written in Swift 3.0.
UIImageView *sampleImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sample"]];
CGSize size = CGSizeMake(30, 30);
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:sampleImage.bounds
byRoundingCorners:(UIRectCornerBottomRight | UIRectCornerTopLeft)
cornerRadii:size];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
[shapeLayer setPath:[bezierPath CGPath]];
sampleImage.layer.mask = shapeLayer;
Upvotes: 2
Reputation: 2591
I have just done that (For Swift 3, but it might help you as well), You should have an outlet to your image, for example called yourImage and then do this On viewDidLoad:
let shapeLayer = CAShapeLayer()
shapeLayer.path = UIBezierPath(roundedRect: yourImage.bounds, byRoundingCorners: [.bottomLeft, .bottomRight], cornerRadii: CGSize(width: 30, height: 30)).cgPath
yourImage.layer.mask = shapeLayer
Upvotes: 2