View从Xib初始化流程

  1. 通过代码从xib读取View
DateBoardView *view = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].firstObject;
  1. view的初始化方法分别为
- (instancetype)init; (不走此方法)
- (instancetype)initWithFrame:(CGRect)frame;  (不走此方法)
- (instancetype)initWithCoder:(NSCoder *)coder;  (先走此方法)
- (void)awakeFromNib;  (后走此方法)
  1. 通过xib创建View,只走下2个方法
//走下2个方法.且均可正常获取Frame值
- (instancetype)initWithCoder:(NSCoder *)coder;
- (void)awakeFromNib;

OC复习/UI基础

你可能感兴趣的:(View从Xib初始化流程)