Skip to content

Instantly share code, notes, and snippets.

@kyleclegg
Created August 14, 2014 08:57
Show Gist options
  • Save kyleclegg/0b6333d30f95b39419b8 to your computer and use it in GitHub Desktop.
Save kyleclegg/0b6333d30f95b39419b8 to your computer and use it in GitHub Desktop.
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