一、xib文件
- 加载xib文件:xxx.xib --> 编译 --> xxx.nib
- 方式一:
NSArray *objs = [[NSBundle mainBundle] loadNibNamed:@"xxx" owner:nil options:nil];
[self.view addSubview:objs[1]];
- 方式二:
// 一个UINib对象就代表一个xib文件
UINib *nib = [UINib nibWithNibName:@"xxx" bundle:[NSBundel mainBundle]];
// 一般情况下,bundle参数传nil,默认就是mainBundle
UINib *nib = [UINib nibWithNibName:@"xxx" bundle:nil];
NSArray *objs = [nib instantiateWithOwner:nil options:nil];
[self.view addSubview:[objs lastObject]];