网址: http://blog.csdn.net/sqc3375177/article/details/16820833
1. 引入XIB代码
- (void)viewDidLoad
{
[super viewDidLoad];
//获得nib视图数组
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"CustomView" owner:self options:nil];
//得到第一个UIView
UIView *tmpCustomView = [nib objectAtIndex:0];
//获得屏幕的Frame
CGRect tmpFrame = [[UIScreen mainScreen] bounds];
//设置自定义视图的中点为屏幕的中点
[tmpCustomView setCenter:CGPointMake(tmpFrame.size.width / 2, tmpFrame.size.height / 2)];
//添加视图
[self.view addSubview:tmpCustomView]
}
网友评论