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

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;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容