设置状态栏色调颜色 [英] Set Status Bar Tint Colour

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

问题描述

我有一个标签栏应用程序,状态栏色调设置为默认值 - 所以在我的应用程序中它总是我选择的蓝色。

I have an tabbed bar application and the status bar tint colour is set to default - so it is always my selected blue colour throughout my app.

但是,在一个视图,我隐藏了我的导航栏,如下所示:

However, in one view, I am hiding my Navigation Bar like so:

[self.navigationController setNavigationBarHidden:YES];

这是在 viewWillAppear 方法和视图是可访问的,因为它是我的应用程序的一个选项卡。

This is in the viewWillAppear method and the view is accessible as it is one of the tabs of my app.

我隐藏它的原因是因为我想放一个工具栏(大约有6个按钮)在它的位置。

The reason I am hiding it, is because I would like to put a toolbar (with about 6 buttons) in its place.

我已设置工具栏的色调颜色,但此视图上的状态栏始终为黑色。有没有办法重新设置此视图的状态栏,或者是否有更好的方法来隐藏导航栏以保留状态栏色调。

I have set the tint colour of my toolbar, however, the status bar on this view is always black. Is there a way to re-set the status bar for this view, or is there a better way to hide the navigation bar in order to retain the status bar tint colour.

UPDATE 我在某处读到当着色设置为默认值时,状态栏的颜色将是标题中最低像素的颜色。

UPDATE I read somewhere that when tinting is set to default, the colour of the status bar will be the colour of the lowest pixel in the header.

我曾尝试将导航栏隐藏在故事板中,并尝试将色调颜色更改为自定义,但这也没有效果。

I have tried hiding the navigation bar in storyboards and have also tried changing the tint colour to 'Custom' but this also had no effect.

这两个截图可能说明我的问题。切换导航栏会更改状态栏颜色。这是有问题的视图嵌入的导航控制器。

These two screenshots might illustrate my issue. Toggling the navigation bar changes the status bar colour. This is the navigation controller which the view in question is embedded in.

推荐答案

啊!我有一个有效的解决方案......虽然是一个非常肮脏和临时的解决方案。

Ahh!!! I have a working solution... albeit a very dirty and makeshift solution.


  1. 只需隐藏故事板中的导航栏(如图所示)有问题 - 取消选中显示导航栏)。

  2. 将导航栏拖到视图中。

  3. 将它的 Alpha 设置为0并取消选中启用用户交互 - 不要隐藏

  4. 确保导航栏位于顶部 - 如下图所示。

  1. Simply hide the navigation bar in storyboards (As shown in image in question - uncheck Shows Navigation Bar).
  2. Drag a Navigation Bar into the view.
  3. Set it's Alpha to 0 and uncheck User Interaction Enabled - DO NOT MAKE HIDDEN
  4. Make sure the Navigation Bar is on the top - as shown in following image.

这样你的状态栏就会在没有显示导航栏的情况下选择正确的颜色。

This way your status bar will pick up the correct colour without showing a Navigation Bar.

希望更有弹性/更好的方法来做到这一点在最近的Xcode更新中。

Hopefully a more resilient/nicer way to do this will be in a recent Xcode update.

顶级提示: 要使工具栏看起来像导航栏:

Top Tip: To make a toolbar look like a navigation bar:


  1. 将工具栏-1定位在Y轴上

  2. 创建一个标签(没有文字),高度为44像素,宽度为320像素,位置为0,0。这将是标签栏的底部边框。为获得最佳效果,请截取应用页面的屏幕截图并使用软件获取边框的颜色 - 这是阴影开始前标签中最暗的部分(使用此颜色作为标签的背景)。

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

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