Created
March 17, 2015 01:47
-
-
Save teerapap/ce29975d73682cb75453 to your computer and use it in GitHub Desktop.
Make custom view from xib and show in interface builder
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
-(instancetype) initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) | |
{ | |
// Initialization code. | |
[self loadFromNib]; | |
} | |
return self; | |
} | |
-(void)awakeFromNib { | |
[super awakeFromNib]; | |
[self loadFromNib]; | |
} | |
-(void)loadFromNib { | |
UIView *v =[[[NSBundle bundleForClass:[self class]] loadNibNamed:@"Test" owner:self options:nil] firstObject]; | |
[self addSubview:v]; | |
v.frame = self.bounds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment