改变iOS中的导航栏和状态栏 的背景色和字体颜色

先看效果

这是系统默认的效果

这是改变后的效果


具体的实现方式:

  • 1.在info.plist添加View controller-based status bar appearance字段并将值设置成NO
  • 2.然后在Appdelegate里面添加:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

//下面两句

[application setStatusBarHidden:NO];

[application setStatusBarStyle:UIStatusBarStyleLightContent];

return YES;

}
  • 3.给navigationController设置新的背景色和字体颜色
self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];

self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];

只需要这简单的三步即可实现

你可能感兴趣的:(iOS学习,ios7,状态栏,导航栏)