iOS7 - 具有特定颜色的状态栏 [英] iOS7 - Status bar with specific color

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

问题描述

是否可以将状态栏文字和电池图标更改为特定颜色,例如红色?

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

我已经阅读了一些关于此的文章,建议我使用setStatusBarStyle。但是我没有选择设置特定的颜色。

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


编辑:

我试图在apple dev论坛上找到答案,但不幸的是我找不到它。 iOS7中UIStatusBar的可用颜色为黑色和白色。

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.

也许你可以尝试下面的Sulthan的帖子,但似乎并不容易,至少对我而言。似乎只需要简单的换色就需要这么多的努力。所以我认为这是不可能的,至少在简单方面是这样。

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 :)

推荐答案

警告 - 一般情况下,App Store评论员不会很好地更改颜色。

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


  1. 您可以隐藏默认状态栏并添加自己的状态栏。这需要显示时间,电池信息,网络状态等。这不是一个不可能的解决方案,不难实现,但它需要时间,并且它看起来不像所有设备上的本机状态栏。

  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.

您可以在白色状态栏上显示部分透明的视图,并以这种方式更改颜色。但是,它也会更改状态栏背景的颜色。

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.

您可以使用未记录的API。状态栏是一个系统窗口(不是由 [UIApplication windows] 返回)但有一些方法可以访问它(例如,参见Window Registry 可以访问所有应用程序窗口。然后你可以使用反射(obj.c运行时)来检查状态栏上哪些方法可用并尝试更改颜色(参见 UIStatusBar UIStatusBarWindow )也可以将原生状态栏绘制到图像中,用彩色像素替换白色像素,然后在原始状态栏上绘制生成的图像。

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.

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

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