Created
January 22, 2013 10:54
-
-
Save jagregory/4593780 to your computer and use it in GitHub Desktop.
Category to add CSS border-radius style corner radii, where you can specify which corners to round.
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
@interface UIView(Corners) | |
- (void)cornerRadius:(float)radius forCorners:(UIRectCorner)corners; | |
@end |
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> | |
#import "UIView+Corners.h" | |
@implementation UIView(Corners) | |
-(void)cornerRadius:(float)radius forCorners:(UIRectCorner)corners{ | |
CAShapeLayer* mask = [CAShapeLayer layer]; | |
mask.path = [UIBezierPath bezierPathWithRoundedRect:self.bounds | |
byRoundingCorners:corners | |
cornerRadii:CGSizeMake(radius, radius)].CGPath; | |
self.layer.mask = mask; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment