隐藏导航栏时的假状态栏颜色 [英] Fake Status Bar Color when Navigation Bar is hidden

查看:110
本文介绍了隐藏导航栏时的假状态栏颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到状态栏和问题的问题导航栏。默认情况下, UINavigationController 的导航栏延伸到状态栏后面并为其着色(左侧屏幕截图)。

I'm running into an issue with status bars & navigation bars. By default the navigation bar of UINavigationController extends behind the status bar and colors it (left screenshot).

当使用搜索栏,我隐藏导航栏。这会导致未着色的状态栏。 Apple的Mail应用程序没有这个问题。

When the search bar is used, I hide the navigation bar. This results in an uncolored Status Bar. Apple's Mail app does not have this issue.

除了创建一个具有背景颜色的单独UIView并将其放在状态栏后面之外,还有其他解决方案吗?

Is there any other solution than creating a separate UIView with a background color and placing it behind the status bar?

这是我想要完成的事情:

Here's what I'd like to accomplish:

推荐答案

在您的IB(或编程)中,尝试检查顶部栏的模拟指标:您应该将其设置为从不透明到半透明(导航栏)。

In your IB (or programatically), try to check the simulated metrics for the top bar: you should set it from opaque to translucent (navigation bar).

注意:默认情况下,导航栏是半透明的。您应该获得免费的彩色**状态栏。

Note: By default, the navigation bar is translucent. You should get the "colored"** status bar for free.

**由 UISearchBar.appearance定义()。barTintColor

这篇关于隐藏导航栏时的假状态栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆