Skip to content

Instantly share code, notes, and snippets.

@teerapap
Created March 17, 2015 01:47
Show Gist options
  • Save teerapap/ce29975d73682cb75453 to your computer and use it in GitHub Desktop.
Save teerapap/ce29975d73682cb75453 to your computer and use it in GitHub Desktop.
Make custom view from xib and show in interface builder
-(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