Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Round two corners on UIView
Easy helper method:
- (void)setMaskTo:(UIView *)view byRoundingCorners:(UIRectCorner)corners
{
CGFloat cornerRadius = 6.0;
UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
CAShapeLayer *shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
view.layer.mask = shape;
}
Call like so:
[self setMaskTo:imageView byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft];
From: http://stackoverflow.com/a/11255791/654870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.