1.設(shè)置view的 custom class (非files owner)
2.初始化
(1) 外部加載xib
XpView *xp = [[[NSBundle mainBundle]loadNibNamed:@"XpView" owner:self options:nil] lastObject];
xp.frame = CGRectMake(0, 300, 375, 150);
[self.view addSubview:xp];
(2)內(nèi)部加載xib
+ (instancetype)shareXpView {
return [[[NSBundle mainBundle] loadNibNamed:@"XpView" owner:self options:nil] lastObject];
}
3.自定義屬性
- (void)awakeFromNib {
[super awakeFromNib];
NSLog(@"%s", __func__);
[self setup];
}