iOS7中修改StatusBar的显示颜色
iOS7中修改StatusBar的显示颜色
效果图如下:
在iOS7中想手动修改statusBar的颜色,第一步需要做的就是在plist文件中设置View controller-based status bar appearance值为NO
第二步就是在代码中实现了,如下所示:
//
// RootViewController.m
// statusBar
//
// Copyright (c) 2014年 Y.X. All rights reserved.
//
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// 4秒钟之后改变状态
[self performSelector:@selector(delayRun)
withObject:nil
afterDelay:4.f];
}
- (void)delayRun
{
// 动画改变背景色
[UIView animateWithDuration:1 animations:^{
self.view.backgroundColor = [UIColor blackColor];
}];
/*
可以选择的参数
UIStatusBarStyleLightContent
UIStatusBarStyleDefault
*/
// 动画改变StatusBar显示颜色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent
animated:YES];
}
@end
以下是实现细节要注意的地方: