- - (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];
定制的UIview如何调用
最新推荐文章于 2021-03-24 12:15:44 发布