Created
November 13, 2012 04:18
-
-
Save naotokui/4063901 to your computer and use it in GitHub Desktop.
UIView RoundedCorner Category
This file contains 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
#import <QuartzCore/QuartzCore.h> | |
@implementation UIView (UIView_RoundCorner) | |
- (void) setCornersRoundedWithRadius: (float) cornerRadius | |
{ | |
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: self.bounds | |
byRoundingCorners: UIRectCornerAllCorners | |
cornerRadii: CGSizeMake(cornerRadius, cornerRadius)]; | |
// Create the shape layer and set its path | |
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = self.bounds; | |
maskLayer.path = maskPath.CGPath; | |
// Set the newly created shape layer as the mask for the image view's layer | |
self.layer.mask = maskLayer; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment