3

I would like to create a notice bar, like the active-phone-call notice bar, whenever my user losses connection to my server.

Is there an easy way to do this? Can't find it in the API, but there must be some supported way - or should I program it manually?

example image

Example: The difference being I want it to be active while in my app and I want to define the text myself.

casparjespersen
  • 3,460
  • 5
  • 38
  • 63

3 Answers3

2

There is no direct API available for doing this, but you can change the status bar color like this

self.window.backgroundColor = [UIColor colorWithRed:0.78f green:0.13f blue:0.11f alpha:1];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

and add another view below with your custom text.

Or, if you just want so put some information in the status bar with a custom color, take a look at KGStatusBar or MTStatusBarOverlay.

tilo
  • 14,009
  • 6
  • 68
  • 85
  • KGStatusBar was not really what I was looking for going in to this question, but it works like a charm in my case. I'll use that, thanks. – casparjespersen Apr 05 '13 at 09:30
2

You can set a window at the statusbar level and actually replace the phone's status bar with your own, if this is what you are asking. The way this can be implemented is found here

However keep in mind that your app may be rejected by Apple in that case.

A lot of apps, are using this for showing for a brief moment some information on the status bar position, then they show the status bar again. The Groupon App was actually doing this and was displaying a UIPageControl when you swiped through their different UITableViews to show you how many UITableViews are available.

Community
  • 1
  • 1
Lefteris
  • 14,550
  • 2
  • 56
  • 95
  • Interesting. But I guess that would also overshadow the current text in the status bar, which I don't want to. – casparjespersen Apr 05 '13 at 09:23
  • Yes, it would hide the status bar. If you just want to display something below the status bar, I suggest you add a view to your window. Is this what you are looking for? It's pretty straightforward then to implement and I could show you how. – Lefteris Apr 05 '13 at 09:27
  • That was also a possibility. But I just explores the KGStatusBar that @tilo linked to, which does the job for me. Thanks for the advice. – casparjespersen Apr 05 '13 at 09:29
  • But what you are showing, is what exactly I pointed you to do :-) – Lefteris Apr 05 '13 at 09:31
1

Here's a decent library I came across the other day called "KGStatusBar, A minimal status bar for iOS." https://github.com/kevingibbon/KGStatusBar. I haven't tried it yet but glancing at the source it seems solid.

Gobot
  • 2,464
  • 1
  • 21
  • 26