使用XIB自定义一个UIView,然后将这个view添加到controller的view

- (void)viewDidLoad
{
    [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];
    UIView *tempMyView = [nib objectAtIndex:0];
    CGRect tempFrame = [[UIScreen mainScreen] bounds];
    [tempMyView setCenter:CGPointMake(tempFrame.size.width/2, tempFrame.size.height/2)];
    [self.view addSubview:tempMyView];
}

 

 

 

 

你可能感兴趣的:(UIView)