- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//创建界面显示的基础对象Windows(手机画布)
self.window=[[UIWindow alloc]init];
//设置界面的大小和设备屏幕一样大
self.window.frame=[[UIScreen mainScreen]bounds];
//3.设置窗口的颜色
self.window.backgroundColor=[UIColor redColor];
//4.创建一个界面管理的控制器
UIViewController *vc=[[UIViewController alloc]init];
//5.创建一个文本框
//CGRect CG开头基本都是结构体,而OC中创建结构体变量,基本都是结构体的名称+make
UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(50, 50, 100, 400)];
//6.设置文本框中的文本内容
lable.text=@"Hello world!";
//7.设置文本颜色为绿色
lable.textColor=[UIColor greenColor];
//8.将标签控件(label)添加到VC的视图中
[vc.view addSubview:lable];
/*创建一个新的VC*/
// UIViewController *buleVC=[[UIViewController alloc]init];
// buleVC.view.backgroundColor=[UIColor blueColor];
// self.window.rootViewController=buleVC;
//9.将VC设置为Window的根试图控制器;
self.window.rootViewController=vc;
//10.最后显示画布
[self.window makeKeyAndVisible];
NSLog(@"didFinishLaunchingWithOptions");
NSLog(@"应用程序载入后执行……");
// Override point for customization after application launch.
return YES;
}
第一个IOS界面之Hello world
最新推荐文章于 2022-08-25 15:35:50 发布