iOS 设置状态栏字体颜色、隐藏UINavigationBar黑

2019-08-06  本文已影响0人  RedRose丶
2835167-359efa0cb658dd0f.png

导航栏颜色和界面背景颜色是一样的,我是定义了一个宏

1、没有隐藏导航栏

2、设置了导航栏的颜色

3、设置了状态栏字体的颜色

4、隐藏了导航栏的黑线

代码如下: [图片上传中...(2835167-23c03e406dc0fc13.png-14f2c6-1565068476926-0)]
2835167-23c03e406dc0fc13.png

导航栏颜色

[[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;
上一篇 下一篇

猜你喜欢

热点阅读