在didFinishLaunchingWithOptions方法中实现:
1.创建视图控制器
UIViewController* controller = [[UIViewController alloc] init];
2.创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor greenColor];// 设置窗口背景色
self.window.rootViewController = controller; //设置窗口视图控制器
3.创建视图
UIView* rootView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
controller.view = rootView;// 关联视图与控制器
4.创建控件并添加到视图
// 创建一个系统风格的按钮
UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMak