Does anyone know how to access to the height of the status bar? I am trying to animate the status bar to the top of the screen.
Related
The main view of my app is a scrollable UICollectionView embedded in a UITabBarController. I'm not using a navigation bar and when the user scrolls he sees the cells behind the status bar, because the status bar has no background.
I've used UIApplication.shared.statusBarView?.backgroundColor = .white in my AppDelegate to apply a background and to make the status bar look like desired.
This works fine, but doesn't look nice when you're presenting a UIAlertController.
The white status bar stays above the dimmed background.
Is there a better way to apply a background to the status bar or a way to keep it behind the UIAlertController background?
You can try to use a UIView with a background color at the top of your presenting UIView.
Height of status bar can come from UIApplication.shared.statusBarFrame. And update your view size when receiving UIApplication.didChangeStatusBarFrameNotification.
When hiding the status bar in a UINavigationController-based app by using:
UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .None)
the UINavigationBar's frame is adjusted. This is because the status bar is a UIView itself and the top of the navigation bar is constrained to the bottom of the status bar. So when the status bar is moved offscreen, the navigation bar moves up with it.
I've tried a number of ways to prevent this behavior. I've tried manually assigning a frame to the navigation bar to no avail. I've tried subclassing UINavigationBar and overriding sizeThatFits() while checking if the status bar is hidden or not and assigning a frame that way. Nothing. I've read other SO posts but no one seems to have a working solution. Help?
Trying to dynamically adjust the time in the status bar in iOS development; to change to a timer or other text in certain views. Can this be done without dynamically hiding/showing the entire status bar? Just trying to replace the time in varying views while keeping the native status bar.
No, you cannot access / adjust / edit the status bar. The most customization you can do is: Hide and change status bar color. You'll have to hide the status bar and show your own UIView in place of it.
First, look at the picture below.
The middle is the message app, the left and right are my apps.
As you can see, in the message app, the status bar and top bar are both grey.
In the left one, the top bar is not translucent. The status bar and the top bar are all white.
In the right one, the top bar is translucent, which is the default style. The top bar is grey, but the status bar is white.
My question is, how to set the status bar to grey? As I can see in the target info part, the status bar style is already 'grey style(default). But it runs in white in my iPhone 5 iOS 7.1.1.
It turns out that #Panayot Panayotov is right. In Navigation controller, everything is fine.
I have compared the Navigation controller and Navigation bar alone. It turns out that in Navigation controller, the Navigation bar's x, y, width and height is 0, 0, 0, 0, which means it is right behind the status bar and also with a autolayout size. Since the status bar is translucent in iOS7, the color of the status bar and navigation bar are the same.
If you use Navigation bar alone, it has a fixed height 44, which can not be changed. That height can't cover the status bar and navigation bar items together. So they colors are different.
Finally the answer is to use navigation controller, not using navigation bar alone.
I've read a few questions here and searched around a bit but nothing seems to solve my problem. I have a side navigation controller of which I am sliding the status bar (using a technique outlined here: Moving status bar in iOS 7).
In any event, when I hide the status bar to begin the slide (as soon as I tell the view to hide the status bar and add a fake one), the entire view moves up behind my faux status bar. Is there any way to move the view down so that the faux status bar appears directly above the view?
may be some autolayout issueAs there is no status bar , the view frame went to frame.origin.y=0. Try setting the frame to origin.y=20 before you hide the status bar.
If you are adding fake status bar as subview to mainView. set frame of fake status bar view to (origin.y=-20)