Change status bar colour in slide out menu

故事扮演 提交于 2019-12-12 00:27:16

问题


I have a slide out menu and no matter what I try, I can't get the status bar area colour to change. I don't know what's wrong.

Picture 1:

Picture 2:

Picture 1 shows the app with the menu out. Picture 2 shows how the storyboard layout

I would have thought this would be simple as I've changed the global status bar colour using UINavigationBar appearance

Does anyone know what I'm doing wrong?


回答1:


You can use this slide menu library: https://github.com/arturdev/AMSlideMenu

Here you can customize status bar by any view. Just call:

- (void)fixStatusBarWithView:(UIView *)view;

here view must be with height of 20px;




回答2:


The status bar in iOS7 is transparent. From Apple:

Because the status bar is transparent, the view behind it shows through. The style of the status bar refers to the appearance of its content, which includes items such as time, battery charge, and Wi-Fi signal. Use a UIStatusBarStyle constant to specify whether the status bar content should be dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent).

So if it is not changing although you have altered the value in IB, you could try to set the value programmatically, like so:

- (UIStatusBarStyle)preferredStatusBarStyle
{
     return UIStatusBarStyleLightContent; //or UIStatusBarStyleDefault
}

The above only changes the color of the text and icons in the status bar between black (UIStatusBarStyleDefault) and white (UIStatusBarStyleLightContent).

As stated by Apple, the bar itself is translucent, so it will be the same color as the view behind it.




回答3:


For anyone that's using SASlideMenu and wondering how to do this. The fix is simple, just add a view to Slide Menu Root View Controller that covers the status bar area. When you change the background colour of this view, it colours the status bar area on the menu.



来源:https://stackoverflow.com/questions/20890945/change-status-bar-colour-in-slide-out-menu

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