In iOS 7 the UIStatusBar
has been designed in a way that it merges with the view like this:
(GUI designed by Tina Tavčar)
It is cool, but it will somewhat mess up your view when you have something at the top part of your view, and it becomes overlapped with the status bar.
Is there a simple solution (such as setting a property in info.plist) that can change the way it works [not overlapping] back to how it is in iOS6?
I know a more straightforward solution is to have
self.view.center.x
+ 20 points for every single view controller, but changing them will screw other dimensions up (having a differentself.view.center.x
can cause problem to custom segues, etc.) and suddenly it turns into a tedious job that is best to be avoided.I'll really be glad if someone can provide me an one-liner solution for this.
P.S. I know I can hide the status bar by doing things like having
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
In didFinishLaunchingWithOptions
method, but that's a workaround, a shortcut avoiding the problem, so I don't consider that a real solution.
As using
presentViewController:animated:completion:
messed-up thewindow.rootViewController.view
, I had to find a different approach to this issue. I finally got it to work with modals and rotations by subclassing the UIView of my rootViewController..h
.m
You now have a strong workaround for iOS7 animations.
If you don't want your view controllers to be overlapped by the status bar (and navigation bars), uncheck the "Extend Edges Under Top Bars" box in Interface Builder in Xcode 5.
I am late for this Answer, but i just want to share what i did, which is basically the easiest solution
First of all-> Go to your
info.plist
File and add Status Bar Style->Transparent Black Style(Alpha of 0.5)Now ,here it Goes:-
Add this code in your AppDelegate.m
If you're using Interface builder, try this:
In your xib file:
1) Select the main view, set the background color to black (or whatever color you want the status bar to be
2) Make sure the background is a self contained subview positioned as a top level child of the controller's view.
Move your background to become a direct child of the controller's view. Check the autosizing panel to be sure that you've locked all frame edges, activated both flexibility axes, and if this is a UIImageView, set the content mode to Scale to fill. Programmatically this translates to contentMode set to UIViewContentModeScaleToFill and has its auto resizing mask set to (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight).
3) Now move everything that is locked to the top - down by 20 pts and set a iOS 6/7 delta Y to -20.
All top level children that are locked to the top frame in the autosizing panel need to be moved down by 20pts and have their iOS 6/7 delta Y set to -20. (Cmd select all of those, and click down arrow 20 times - is there a better way anyone?)
4) Adjust the iOS 6/7 delta height of all of the above items that had a flexible height. Any of the items that were locked to the frame top and bottom and had flexible height enabled in the autosizing panel must also have their iOS 6/7 delta height set to 20. That includes the background view mentioned above. This may seem anti-intuitive, but due to the order in which these are applied, it is necessary. The frame height is set first (based on device), then the deltas are applied, and finally the autosizing masks are applied based upon the offset positions of all of the child frames - think it through for a bit, it will make sense.
5) Finally, items that were locked to the bottom frame but not the top frame need no deltas at all.
That will give you the identical status bar in iOS7 and iOS6.
On the other hand, if you want iOS7 styling while maintaining iOS6 compatibility, then set the delta Y / delta height values to 0 for the background view.
To see more iOS7 migration info read the full post: http://uncompiled.blogspot.com/2013/09/legacy-compatible-offsets-in-ios7.html
This may be a overwhelming problem if you use Auto layout because you can not directly manipulate frames anymore. There is a simple solution without too much work.
I ended up writing an utility method in an Utility Class and called it from all the view controllers's
viewDidLayoutSubviews
Method.Override your
viewDidLayoutSubviews
method in the view controller, where you want status bar. It will get you through the burden of Autolayout.Steps For Hide the status bar in iOS 7:
1.Go to your application info.plist file.
2.And Set, View controller-based status bar appearance : Boolean NO
Hope i solved the status bar issue.....