Skip to content

Instantly share code, notes, and snippets.

@spetschu
Created February 18, 2014 22:43
Show Gist options
  • Save spetschu/9082002 to your computer and use it in GitHub Desktop.
Save spetschu/9082002 to your computer and use it in GitHub Desktop.
UIView with rounded rectangle background
#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
@spetschu
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment