Write some text in (or on) UIStatusBar

ⅰ亾dé卋堺 提交于 2019-12-21 20:25:16

问题


I know, it's a strange question ^^,

I would like to know if there is a way to write some text in (or on) the UIStatusBar. In particular I want to write some text on the Status Bar when the user press a UIButton.

Thanks!


回答1:


I'm not sure if you can draw directly into the status bar, but you should be able to draw on top of it in a custom view. You can get the status bar's frame using:

CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];

And you can get the application's main window (presumably the status bar's superview) using:

UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

You should be able to add your custom view directly to the key window in the status bar's frame. For an example of an app that appears to "modify" the status bar, take a look at Reeder.




回答2:


No, the status bar is a system-controlled element. It's content cannot be modified by a third-party application.




回答3:


Check out this work in progress: https://github.com/maciekish/APStatusBarExtensions




回答4:


MTStatusBarOverlay is what you want :

https://github.com/myell0w/MTStatusBarOverlay

Definitely the easier to use !



来源:https://stackoverflow.com/questions/4328664/write-some-text-in-or-on-uistatusbar

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