标签:
1.新建一个xib视图
2.更改视图大小
3.将自动布局关闭
4.添加想要的控件到该视图上
5.将视图添加到控制器上
- (void)viewDidLoad { [super viewDidLoad]; 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]; }
标签:
原文地址:http://www.cnblogs.com/hxwj/p/4725892.html