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: The difference being I want it to be active while in my app and I want to define the text myself.
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.
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.
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.
Related
This might be a beginner question, but I noticed something interesting in the new Apple Music app. When switching from one view to another, the status bar text colour seems to change in real time rather than all at once when the next view loads.
Check out this screen recording to see what I mean:
http://f.cl.ly/items/2A0a3Q3i2O2d2O3u3q1m/statusBar_1.mp4
Closeup: http://f.cl.ly/items/182r3n3Z1m1y0y1W0j2J/statusBar_2.mov
How would I achieve this same effect? For instance, when transitioning to another view controller modally, how would I get the status bar style to change dynamically like this rather than when the next view loads? Is it even possible? Is Apple using some private API, or is it just a really simple trick I'm missing? Sorry if this is a beginner question, but I don't think I've ever seen another app do this.
Nothing you’re missing—there’s definitely no API to do that. I’ve seen a couple of third-party apps do something similar, probably by finding the status bar window, snapshotting it, and doing clever things with the resulting image, but that’s pretty fragile. As always, if you’d like an API for something, you should file an enhancement request.
My app is in landscape and uses a UINavigationController as its RootViewController. My goal with it is:
Disable the normal iOS StatusBar ( I know how to do that and already did it )
Have a semi-transparent StatusBar (a view) above the UINavigationBar, so that I can show custom information on it
Parts of the content of my main view must be visible underneath my custom StatusBar (exactly like it works with the normal UIStatusBar, just that I don't want the clock and battery and want to show my own information on it)
How can I best achieve this?
A quick search on GitHub gave me multiple libraries that offer the exact functionality you are looking for.
MTStatusBarOverlay
KGStatusBar
CWStatusBarNotification
FDStatusBarNotifierView
BWStatusBarOverlay
WTStatusBar
TWStatus
Try them out, test them and see which one is best for you.
If none of them are good enough, you should get an idea on how to achieve this functionality using the source code those libraries provide.
iOS 7 Human Interface Design, page 143 says:
Don’t create a custom status bar. Users depend on the consistency of
the system-provided status bar. Although you might hide the status bar
in your app, it’s not appropriate to create custom UI that takes its
place.
iOS Human Interface Guidelines
So i only want to display the time for the status bar. Is there a way to format the status bar to only show the time, or am I going to have to just implement a time display object and hide the status bar? Any help would be great!! Thanks
There is no public API to modify the status bar. You can implement a status bar of your own, but note that partially implementing a status bar is against Apple's AppStore rules and potentially unsafe (more specifically, replacing the functionality of a status bar which the users are accustomed to). For example, see here:
We found your app uses system-provided items in a non-standard manner,
which is not in compliance with the App Store Review Guidelines.
Specifically, we found your app animates the status bar. Please see
the attached screenshot for reference to the issue [screen shot shows
the custom status bar saying "Up To Date"].
Learn more about system-provided items in the iOS Human Interface
Guidelines, sections: "System-Provided Buttons and Icons" and "iOS UI
Element Usage Guidelines."
If you still want to implement you can either hide the system status bar and a new view to each of your views, or create a new UIWindow with a windowLevel of UIWindowLevelStatusBar + 1 and a frame of [UIApplication sharedApplication].statusBarFrame and a label, will give you exactly what you need.
is it possible to change status bar text and battery icon to specific color, for example red color?
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
EDIT :
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.
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 :)
Warning - in general, changing the color will not be received well by App Store reviewers.
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.
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.
I'd like to use this effect (not necessarily blue) when I'm synching my app to my server. I've searched the interwebs and apple dev forums but to no avail.
Another way to do this (though it gives you very little control over how the double status bar looks) is to simulate an audio session. See the following question & answer: SBStatusBarController instance
There is no way to do this nicely as Apple does this. There are two ways to do at least something close to this:
You can try to set status bar style to UIStatusBarStyleBlackTranslucent and plea a little bit with background images under the status bar that will affect a color a little bit.
You can take a look through the code by following links — http://www.cocoabyss.com/uikit/custom-status-bar-ios/ and https://github.com/myell0w/MTStatusBarOverlay/ this two code samples implements an overlay above the status bar that fools a user. Achieved result maybe pretty close to what you show in your screenshot.