一个app只有一个UIApplication
// 1.整个app中只有一个UIApplication
UIApplication *app = [UIApplication sharedApplication];
1.app图标上的提醒数字
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[app registerUserNotificationSettings:settings];
app.applicationIconBadgeNumber = 10;
- 手机左上角显示联网状态
// 设置联网状态
app.networkActivityIndicatorVisible = YES;
3.用手机Safari浏览器打开网页
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
[[UIApplication sharedApplication] openURL:url];
4.隐藏状态栏
- 第一种
- (BOOL)prefersStatusBarHidden {
return YES;
}
-
第二种
在info.plist中添加一个属性:View controller-based status bar appearance,如下图:
5.修改状态栏的字体颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}