先建立繼承UIView的class,
接下來建立xib檔,並在xib中設定class為剛剛建立的class,
把xib內的物件和class link 起來,
並在initWithFrame中加入
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
NSArray *viewXib = [[NSBundle mainBundle] loadNibNamed:@"viewer" owner:self options:nil];
self = [viewXib objectAtIndex:0];
}
return self;
}