APP开发学习
//添加xib文件到窗口中
NSArray *views = [[NSBundle mainBundle]loadNibNamed:@"View" owner:self options:nil];
[self.window addSubview:[views lastObject]];
//手写代码添加一个label
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(320/2-140/2, 80, 140, 40)]; //添加label
label.text = @"Hello world"; //添加文本
label.backgroundColor = [UIColor cyanColor]; //加背景颜色
label.textAlignment = NSTextAlignmentCenter; //文字居中
[self.window addSubview:label]; //将label添加到窗口中
[label release];
时间: 2024-10-23 11:46:50