实现的四个功能这个系列主要写一些平时ios开发和学习过程中所记录的问题、随笔和解决方法,我会尽量用更多的截图或者gif图来还原我的开发现场,在执行个人备忘录功能的同时希望对你有所帮助。
1.设置角标
角标- (IBAction)bageValue:(id)sender {
//获取UIApplication对象 UIApplication *app = [UIApplication sharedApplication];
//注册用户通知
UIUserNotificationSettings *notice = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[app registerUserNotificationSettings:notice]; app.applicationIconBadgeNumber = 10; }
2.设置联网状态
联网中的菊花- (IBAction)netState:(id)sender {
UIApplication *app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
}
3.设置状态栏
有动画- (IBAction)statueBar:(id)sender {
UIApplication *app = [UIApplication sharedApplication];
app.statusBarHidden = YES;
//有动画的版本(已过期)
//[app setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
注意:默认通过UIViewcontroller管理,要在info.plist里面解除控制
info.plist当然,可以利用默认的UIViewcontroller管理状态栏,具体方法如下:
//通过UIViewcontroller管理
//1.隐藏通知栏
-(BOOL)prefersStatusBarHidden{
return YES;
}
//2.设置通知栏样式
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleBlackOpaque;
}
4.打开网页
跳转Safari- (IBAction)openURL:(id)sender {
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:@"http://www.baidu.com"]];
}
网友评论