您的位置:首页 > 产品设计 > UI/UE

IOS初级:UIwindow

2015-06-01 22:17 351 查看
AppDelegate.h

@property (strong, nonatomic) UIWindow *window;


AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor yellowColor];
[self.window makeKeyAndVisible];
// Override point for customization after application launch.
return YES;
}


UIWindow的父类UIView,代码中的initWithFrame方法、backgroundColor成员均来自UIView。

其中initWithFrame方法的参数是CGRect类型的,返回的是一个UIWindow的指针。

UIScreen的类方法mainScreen的返回是设备内部屏幕信息的一个UIScreen的指针。

UIScreen的成员bounds是一个CGRect类型的值,表示全尺寸屏幕的坐标。

UIColor是生成颜色值的类,这里不多说。

UIWindows的方法makeKeyAndVisible是让当前的这个UIWindow类型的对象成为应用程序的主窗口,并使他可见。

CGRect坐标表示方法:相对与父窗口的偏移x,y和本身的长和宽。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: