iOS7 - Status bar with specific color

旧巷老猫 提交于 2019-12-30 05:18:28

问题


is it possible to change status bar text and battery icon to specific color, for example red color?

I have read some article about this, suggesting me to use setStatusBarStyle. But I don't have option to set to specific color.

So, is it possible to do this? Thanks in advance


EDIT :

I was trying to find the answer at apple dev forum, but unfortunately I can't find it. The available color for UIStatusBar in iOS7 is black and white.

Maybe you can try Sulthan's post below, but seems not easy, at least for me. Seems need so much effort for just simple color changing. So I don't think this is possible, at least in easy way.

Anyway, thanks for helping me :)


回答1:


Warning - in general, changing the color will not be received well by App Store reviewers.

  1. You can hide the default status bar and add your own. This would require displaying time, battery information, network state etc. It's not an impossible solution, not hard to implement but it will take time and it won't look exactly like the native status bar on all the devices.

  2. You can show a partially transparent view over the white status bar and change the color this way. However, it will also change the color of the status bar background.

  3. You can use undocumented API. Status bar is a system window (not returned by [UIApplication windows]) but there are ways to gain access to it (see, for example, Window Registry to gain access to all application windows). Then you can use reflection (obj.c runtime) to check which methods are available on the status bar and try to change the colors (see UIStatusBar and UIStatusBarWindow) It also might be possible to draw the native status bar into an image, replace white pixels with colored pixels and then draw the resulting image over the original status bar.



来源:https://stackoverflow.com/questions/19834045/ios7-status-bar-with-specific-color

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