一嫩实、UIApplication
1.打開網(wǎng)頁
// URL:資源路徑
// URL:協(xié)議頭://域名+路徑 http,https,file,tel
// 協(xié)議頭:
// 打開網(wǎng)頁 @"http://www.baidu.com"
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
[[UIApplication sharedApplication] openURL:url]; //跳到Safari打開網(wǎng)頁
2.隱藏狀態(tài)欄
// 獲取UIApplication
UIApplication *app = [UIApplication sharedApplication];
// 隱藏狀態(tài)欄
// [app setStatusBarHidden:YES];
[app setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
// 在iOS7以后恨狈,狀態(tài)欄默認由控制器決定
// 隱藏狀態(tài)欄
//- (BOOL)prefersStatusBarHidden
//{
// return YES;
//}
//- (UIStatusBarStyle)preferredStatusBarStyle
//{
// return UIStatusBarStyleLightContent;
//}
3.設(shè)置提醒數(shù)字
// 1.整個app中只有一個UIApplication
// UIApplication *app = [[UIApplication alloc] init];
UIApplication *app = [UIApplication sharedApplication];
// 2.UIApplication一般用來做一些應(yīng)用級別的操作(app的提醒框帚戳,聯(lián)網(wǎng)狀態(tài)峻仇,打電話樱蛤,打開網(wǎng)頁壮莹,控制狀態(tài)欄)
// UIApplication *app1 = [UIApplication sharedApplication];
// 設(shè)置appIcon提醒數(shù)字,必須注冊用戶通知
app.applicationIconBadgeNumber = 10;
// 創(chuàng)建用戶通知
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
// 注冊用戶的通知
[app registerUserNotificationSettings:settings];
// 設(shè)置聯(lián)網(wǎng)狀態(tài)
app.networkActivityIndicatorVisible = YES;
二荣德、UIWindow
1.AppDelegate.h中的window屬性
// 程序啟動完成的時候
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 1.創(chuàng)建窗口,注意窗口必須要有尺寸隧土,尺寸跟屏幕一樣大的尺寸,窗口不要被釋放
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor redColor];
// 2.創(chuàng)建窗口的根控制器
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor yellowColor];
[vc.view addSubview:[UIButton buttonWithType:UIButtonTypeContactAdd]];
// 如果設(shè)置窗口的根控制器,默認就會把控制器的view添加到窗口上
// 設(shè)置窗口的根控制器命爬,默認就有旋轉(zhuǎn)功能
self.window.rootViewController = vc;
// [self.window addSubview:vc.view];
// 3.顯示窗口
[self.window makeKeyAndVisible];
return YES;
}
2.窗口是有層級關(guān)系
UIWindowLevelNormal < UIWindowLevelStatusBar < UIWindowLevelAlert
// 設(shè)置窗口的層級關(guān)系
self.window1.windowLevel = UIWindowLevelStatusBar;