1 创建一个xib并使之与一个自定义的View相关联
2 在自定义的View中参考如下代码:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code.
//MyView is xib name
[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];
[self addSubview:self.view];
}
return self;
}
参考:http://*.com/questions/5056219/uiview-and-initwithframe-and-a-nib-file-how-can-i-get-the-nib-file-loaded
http://blog.****.net/yu413854285/article/details/7734198
http://nscookbook.com/2013/01/recipe-6-creating-a-custom-uiview-using-a-nib/