
导航栏颜色和界面背景颜色是一样的,我是定义了一个宏
1、没有隐藏导航栏
2、设置了导航栏的颜色
3、设置了状态栏字体的颜色
4、隐藏了导航栏的黑线
代码如下:

导航栏颜色
[[UINavigationBar appearance] setBarTintColor:navigationBarColor];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:17]}];
去掉导航黑线、导航栏透明
// 导航栏透明
//[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
界面中使用
self.view.backgroundColor = navigationBarColor;
设置navigationbar的半透明
[self.navigationController.navigationBar setTranslucent:NO];
设置状态栏字体颜色为白色
self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
网友评论