转载

iOS 应用修改状态栏和导航栏颜色

修改状态栏

在 Target::Info 栏里, 找到 Custom iOS Target Properties, 加入一项配置项:

Key: View controller-based status bar appearance Type: Boolean Value: NO

这样, 就可以修改状态栏的字体颜色了, 否则没法改. 然后修改 AppDelegate:

- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts {     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; }

修改导航栏背景和字体颜色

- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts {  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  UINavigationController *nav = [[UINavigationController alloc] init];  nav.navigationBar.tintColor = [UIColor whiteColor];  nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};  nav.navigationBar.barTintColor = [UIColor blueColor];  nav.navigationBar.translucent = NO;  self.window.rootViewController = nav;  [self.window makeKeyAndVisible];  return YES; } 
  • tintColor: 导航栏的按钮(如返回)颜色
  • titleTextAttributes: 标题颜色
  • barTintColor: 背景颜色
  • translucent: 是否透明
正文到此结束
Loading...