Created
August 14, 2014 08:57
-
-
Save kyleclegg/0b6333d30f95b39419b8 to your computer and use it in GitHub Desktop.
Round two corners on UIView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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