038改变状态栏的颜色(扩展知识:关于iOS不同版本的消息通知知识)
效果如下:

ViewController.h
#import <UIKit/UIKit.h> @interface ViewController : UIViewController
@end
ViewController.m
#import "ViewController.h" @interface ViewController ()
- (void)userNotificationDidPush:(UIApplication *)application;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; UILabel *lblMessage = [[UILabel alloc] initWithFrame:CGRectInset(self.view.bounds, , )];
lblMessage.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
lblMessage.text = @"需要在PL文件新增行View controller-based status bar appearance=NO;触摸画面后,切换状态条颜色";
lblMessage.numberOfLines = ;
lblMessage.textAlignment = NSTextAlignmentCenter;
lblMessage.textColor = [UIColor brownColor];
lblMessage.backgroundColor = [UIColor whiteColor];
[self.view addSubview:lblMessage]; self.navigationItem.prompt = @"看看状态栏的颜色变化";
self.navigationItem.title = @"改变状态栏的颜色";
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UIApplication *application = [UIApplication sharedApplication];
//状态栏样式切换
if (application.statusBarStyle == UIStatusBarStyleDefault) {
application.statusBarStyle = UIStatusBarStyleLightContent;
} else {
application.statusBarStyle = UIStatusBarStyleDefault;
} [self userNotificationDidPush:application];
} /**
* 扩展知识:关于iOS不同版本的消息通知知识
*
* @param application 共享的UIApplication单例模式对象实例
*/
- (void)userNotificationDidPush:(UIApplication *)application {
//应用程序图标标记数
//因为registerUserNotificationSettings方法为iOS8的方法,无法在iOS8以下版本使用;所以需要分别处理
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[application registerUserNotificationSettings:settings];
} else {
[application registerForRemoteNotifications];
}
application.applicationIconBadgeNumber = ; //应用程序图标的消息标记数
//self.tabBarItem.badgeValue = @"3"; //底部选项卡的消息标记数 /* 判断Push推送通知是否打开;同上面一样道理需要分别处理
UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
} else {
types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
}
BOOL isEnabledNotification = types & UIRemoteNotificationTypeAlert;
*/
} @end
AppDelegate.h
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *navigationController; @end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h" @interface AppDelegate ()
@end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *viewController = [[ViewController alloc] init];
_navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
_window.rootViewController = _navigationController;
[_window addSubview:_navigationController.view];
[_window makeKeyAndVisible];
return YES;
} - (void)applicationWillResignActive:(UIApplication *)application {
} - (void)applicationDidEnterBackground:(UIApplication *)application {
} - (void)applicationWillEnterForeground:(UIApplication *)application {
} - (void)applicationDidBecomeActive:(UIApplication *)application {
} - (void)applicationWillTerminate:(UIApplication *)application {
} @end
038改变状态栏的颜色(扩展知识:关于iOS不同版本的消息通知知识)的更多相关文章
- Android学习第八弹之改变状态栏的颜色使其与APP风格一体化
公众号:smart_android 作者:耿广龙|loonggg 点击"阅读原文",可查看更多内容和干货 导语:沉浸式状态栏,改变状态栏的颜色使之与APP风格一体化是不是感觉很漂亮 ...
- iOS7改变状态栏文字颜色
1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的 AppDelegate中在 didFinishLaun ...
- 【iOS学习笔记】改变状态栏字体颜色
Step1. info.plist中设置UIViewControllerBasedStatusBarAppearance为NO Step2. AppDelegate.m中添加 - (BOOL)appl ...
- 把所有界面的状态栏字体颜色设置为白色--iOS开发系列---项目中成长的知识一
第一步: 在info.plist中 View controller-based status bar appearance这个属性设置为 View controller-based status ba ...
- colorPrimaryDark无法改变状态栏颜色
设置完colorPrimaryDark后,这个颜色是改变状态栏的颜色的, colorPrimary是改变标题栏背景色的 发现状态栏一直是灰色. 然后在布局文件中 AndroidMainifest.xm ...
- 关于在ios7之后改变状态栏颜色
看到网上都说 在ios7之后要这样设置 首先,须要在Info.plist配置文件里,添加键:UIViewControllerBasedStatusBarAppearance,并设置为YES: 然后,在 ...
- iOS7默认状态栏文字颜色为黑色,项目需要修改为白色。
1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的 AppDelegate中在 didFinishLaun ...
- iOS6 与iOS7以及7以上状态栏的颜色设置
iOS7默认状态栏文字颜色为黑色 修改为白色的方法:(chenyong注意 我的Status bar style 使用的仍是默认值Gray style(default)) 1在Info.plist中设 ...
- iOS之 状态栏字体颜色的设置
前一段时间接手一个项目后,熟悉的过程中发现了不少问题,其中有一个就是关于状态栏的问题. 我们都知道:状态栏字体颜色在不同界面不一样的,原因是系统设置的时候把状态栏的字体颜色的界面控制器设置的yes. ...
随机推荐
- postgre与mysql区别
SQL兼容性 PostgreSQL 9.5 兼容 SQL:2011 子集 http://www.postgresql.org/docs/9.5/static/features-sql-standard ...
- [转]bootstrapTable refresh 方法使用简单举例
原文地址:https://blog.csdn.net/lanyang123456/article/details/55805478 本文就bootstrapTable refresh 方法如何传递参数 ...
- OpenFileDialog对话框Filter属性
OpenFileDialog对话框的Filter属性说明: 首先说明一个示例,分析一下Filter属性的构成:“ Excel文件|*.xls ”,前面的“Excel文件”成为标签,是一个可读的字符串, ...
- C#使用System.IO.Path获取文件路径、文件名
class Program { static void Main(string[] args) { //获取当前运行程序的目录 string fileDir = Environment.Current ...
- C语言 · 方程的解
给出方程组: 11x + 13y + 17z = 2471 13x + 17y + 11z = 2739 已知 x,y,z均为正整数,请你计算 x,y,z 相加和最小为多少. 作者注释:哎呀,不多 ...
- 新浪微博 oauth2.0 redirect_uri_mismatch
新浪微博开放平台出来很久了,现在才开始研究,貌似有点晚了.... 第一次折腾,总是出现这样那样的问题,即使照着别人成功的例子也是一样,这不,开始运行的时候,运行下面的例子,总是报error:redir ...
- Install CasperJS on Windows
Phantomjs installation additionsAppend ";C:\phantomjs" to your PATH environment variable. ...
- Ehcache BlockingCache 源码分析
BlockingCache是对Ehcache进行的扩展,BlockingCache内置了读写锁,不需要用户显示调用. 要彻底分析BlockingCache的原理,需要首先来看一下它内部用到的一些类. ...
- c# 利用反射清除事件
控件的事件清除,除了-=,就只能依靠反射来执行了. /// <summary> /// 清除一个对象的某个事件所挂钩的delegate /// </summary> /// & ...
- android开发(28) 做个 指南针 应用
参考网上的资料,做了个指南针应用玩玩. 步骤: 1.获得 SensorManager. mSensorManager = (SensorManager) getSystemService(SENSOR ...