Set Status Bar Tint Colour

别来无恙 提交于 2019-12-02 05:53:14

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

  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.

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. Position the toolbar -1 on the Y axis
  2. Create a label (with no text) with a height of 44px, width 320px and position at 0,0. This will be the bottom border for the tab bar. For best results, take a screenshot of a page of your app and use software to get the colour of the border - this is the darkest part of the tab before the shadow begins (use this colour as the background of the label).
Change statusBarStyle of application-
[[UIApplication sharedApplication] 
      setStatusBarStyle:UIStatusBarStyleDefault animated:NO];
applefreak

If you are using iOS 6.0, you can set status bar color through plist file. See - How to set status bar tint color on iOS 6?

From iOS 6 release notes;

Status Bar

It is now possible to set status bar tint parameters in your app’s Info.plist file. You might do this to ensure that the status bar color matches your app’s navigation bar color during startup. To set the status bar tint, add the UIStatusBarTintParameters key to your Info.plist file. The value of this key is a dictionary with the appropriate values describing the navigation bar your app has at startup. Inside the dictionary should be the UINavigationBar key, which has a value that is also a dictionary. That dictionary contains the initial navigation bar’s style (with the Style key) and indicates whether it is translucent (with the Translucent key). You can also specify your navigation bar’s tint color (with the TintColor key) or the name of its custom background image (with the BackgroundImage key).

[EDIT]

It seems in iOS 6 the status bar color is automatically determined by the navigation bar color. Before hiding navigation bar can you set the color of navigation bar to your default and see if that makes any difference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!