• <i id='tBPtD'><tr id='tBPtD'><dt id='tBPtD'><q id='tBPtD'><span id='tBPtD'><b id='tBPtD'><form id='tBPtD'><ins id='tBPtD'></ins><ul id='tBPtD'></ul><sub id='tBPtD'></sub></form><legend id='tBPtD'></legend><bdo id='tBPtD'><pre id='tBPtD'><center id='tBPtD'></center></pre></bdo></b><th id='tBPtD'></th></span></q></dt></tr></i><div id='tBPtD'><tfoot id='tBPtD'></tfoot><dl id='tBPtD'><fieldset id='tBPtD'></fieldset></dl></div>
  • <tfoot id='tBPtD'></tfoot>

    <legend id='tBPtD'><style id='tBPtD'><dir id='tBPtD'><q id='tBPtD'></q></dir></style></legend>

  • <small id='tBPtD'></small><noframes id='tBPtD'>

          <bdo id='tBPtD'></bdo><ul id='tBPtD'></ul>

        iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法

        The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)

        • <legend id='BAqoV'><style id='BAqoV'><dir id='BAqoV'><q id='BAqoV'></q></dir></style></legend>

          <small id='BAqoV'></small><noframes id='BAqoV'>

            <tbody id='BAqoV'></tbody>
              <tfoot id='BAqoV'></tfoot>

                • <bdo id='BAqoV'></bdo><ul id='BAqoV'></ul>
                • <i id='BAqoV'><tr id='BAqoV'><dt id='BAqoV'><q id='BAqoV'><span id='BAqoV'><b id='BAqoV'><form id='BAqoV'><ins id='BAqoV'></ins><ul id='BAqoV'></ul><sub id='BAqoV'></sub></form><legend id='BAqoV'></legend><bdo id='BAqoV'><pre id='BAqoV'><center id='BAqoV'></center></pre></bdo></b><th id='BAqoV'></th></span></q></dt></tr></i><div id='BAqoV'><tfoot id='BAqoV'></tfoot><dl id='BAqoV'><fieldset id='BAqoV'></fieldset></dl></div>
                  本文介绍了iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要让嵌入在 UINavigationController 中的特定 ViewController 具有浅色状态栏文本颜色(但其他 ViewController 的行为不同).我知道至少有 3 种方法,但在我的情况下没有一种方法有效.

                  I need to let a specific ViewController embedded in an UINavigationController to have light status bar text color (but other ViewControllers to behave differently). I am aware of at least 3 methods, none of which however work in my case.

                  1. 如何更改状态栏文本iOS 7中的颜色,方法主要是:

                  • 在plist中设置UIViewControllerBasedStatusBarAppearanceYES
                  • 在 viewDidLoad 中执行 [self setNeedsStatusBarAppearanceUpdate];
                  • 添加如下方法:

                  • Set the UIViewControllerBasedStatusBarAppearance to YES in the plist
                  • In viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
                  • Add the following method:

                  - (UIStatusBarStyle)preferredStatusBarStyle{ 
                        return UIStatusBarStyleLightContent; 
                    }
                  

                  在 iOS 7.0.3 上运行,此方法对我不起作用,因为即使在我正确实现了所有 3 个步骤之后,也永远不会调用 preferredStatusBarStyle.

                  Running on iOS 7.0.3, this method does not work for me, since even after I have implemented all 3 steps correctly, preferredStatusBarStyle is never called.

                  UIStatusBarStyle PreferredStatusBarStyle 在 iOS 7 上不起作用,方法主要是:

                  将您的 navigationBarbarStyle 设置为 UIBarStyleBlackTranslucent 将提供白色状态栏文本(即 UIStatusBarStyleLightContent),而 UIBarStyleDefault 将给出黑色状态栏文本(即 UIStatusBarStyleDefault).

                  Setting your navigationBar’s barStyle to UIBarStyleBlackTranslucent will give white status bar text (ie. UIStatusBarStyleLightContent), and UIBarStyleDefault will give black status bar text (ie. UIStatusBarStyleDefault).

                  此方法在 iPhone 上有效,但在 iPad 上无效.

                  This method works fair and square on iPhone, but not on iPad.

                  在plist中设置UIViewControllerBasedStatusBarAppearanceNO,并使用

                  Setting the UIViewControllerBasedStatusBarAppearance to NO in the plist, and use

                  [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
                  

                  这显然不适用于这种情况,因为我只需要为两个 ViewController 指定不同的状态栏颜色.

                  This clearly doesn't apply in this case, since I need to only specify different status bar colors for two of the ViewControllers.

                  感谢大家的帮助!

                  推荐答案

                  对于遇到 UINavigationController 问题的人,我可以建议创建自定义 UINavigationController 并实现 preferredStatusBarStyle 就这样:

                  For people having this problem with a UINavigationController I can recommend creating a custom UINavigationController and implementing the preferredStatusBarStyle on it like this:

                  - (UIStatusBarStyle)preferredStatusBarStyle
                  {
                      return [self.topViewController preferredStatusBarStyle];
                  }
                  

                  这样状态栏样式将是顶视图控制器的样式.现在您可以随意实现视图控制器的 preferredStatusBarStyle.

                  That way the statusbar style will be that of the top view controller. Now you can implement the view controller's preferredStatusBarStyle anyway you like.

                  这篇关于iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  View being blocked by UITransitionView after being presented(呈现后被 UITransitionView 阻止的视图)

                      <bdo id='tLMgP'></bdo><ul id='tLMgP'></ul>
                            <tbody id='tLMgP'></tbody>
                          <i id='tLMgP'><tr id='tLMgP'><dt id='tLMgP'><q id='tLMgP'><span id='tLMgP'><b id='tLMgP'><form id='tLMgP'><ins id='tLMgP'></ins><ul id='tLMgP'></ul><sub id='tLMgP'></sub></form><legend id='tLMgP'></legend><bdo id='tLMgP'><pre id='tLMgP'><center id='tLMgP'></center></pre></bdo></b><th id='tLMgP'></th></span></q></dt></tr></i><div id='tLMgP'><tfoot id='tLMgP'></tfoot><dl id='tLMgP'><fieldset id='tLMgP'></fieldset></dl></div>

                          <tfoot id='tLMgP'></tfoot><legend id='tLMgP'><style id='tLMgP'><dir id='tLMgP'><q id='tLMgP'></q></dir></style></legend>

                          • <small id='tLMgP'></small><noframes id='tLMgP'>