//通过XIB的方式创建视图对象 NSBundle *bundle = [NSBundle mainBundle]; NSArray *array = [bundle loadNibNamed:@"View" owner:self options:nil]; UIView *myView = [array objectAtIndex:0]; //代码方式创建视图对象 CGRect viewRect= CGRectMake(0, 0, 100, 100); UIView *myView = [[UIView alloc] initWithFrame:viewRect];
时间: 2024-10-12 14:24:53