问题
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