Pergunta

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!

Foi útil?

Solução

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.

Outras dicas

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

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

MTStatusBarOverlay is what you want :

https://github.com/myell0w/MTStatusBarOverlay

Definitely the easier to use !

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top