Created
February 18, 2014 22:43
-
-
Save spetschu/9082002 to your computer and use it in GitHub Desktop.
UIView with rounded rectangle background
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 "RoundedRect.h" | |
@implementation RoundedRect | |
-(id) initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self != nil) { | |
[self drawBackground]; | |
} | |
return self; | |
} | |
-(id) initWithCoder:(NSCoder *)aDecoder { | |
self = [super initWithCoder:aDecoder]; | |
if (self != nil) { | |
[self drawBackground]; | |
} | |
return self; | |
} | |
-(void) drawBackground { | |
CALayer *layer = self.layer; | |
layer.cornerRadius = 10.0f; | |
layer.masksToBounds = YES; | |
layer.borderColor = [UIColor blackColor].CGColor; | |
layer.borderWidth = 1.0f; | |
//self.backgroundColor = [UIColor lightGrayColor]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also do-able in interface builder: http://stackoverflow.com/questions/12301256/is-it-possible-to-set-uiview-border-properties-from-interface-builder