Status bar overlaps on my view - ios

I have a UIViewController subclass which when I run the app on iOS 7, the status bar shows on top of my view. Is there a way to avoid this? I do not want the status bar to be hidden. Is there a way to show the status bar above my app. I present my view using presentViewController. Please guide what I am missing?

In Xcode, In storyboard there is an option of iOS6/7 delta. set delta Y to 20 pixel of your view, to make compatible with iOS7.For this you have to disable auto layout, you can use auto resizing.

This is quite common issue. Starting from iOS 7 Status Bar is a part of the controller's view. Apple even have added special attribute of UIView in the Interface Builder: iOS 6/7 Deltas. To fix your problem and make your view look the same in different iOS versions, go to Size inspector and set Delta Y to 20.0.

Related

IOS 11 navigation bar appears smaller than it should

I have a custom navigation bar that worked well until iOS 11. It appears smaller than it should and seems to ignore the status bar height or something.
I set the whole thing programmatically and the height is set to 64.
have you tried to disable (untick) safe area?

iOS - Resizing Navigation Bar height with detail

I want to make a navigation bar that changes height in it's detail view just like the messages app in iOS 10. How can I do that?
Edit:
I am looking to change the height dynamically. SizeThatFits() Permanently changes the height.
If you are trying to do something else that requires the navigation bar to be resized, that's not supported. iOS 11 and Above
Community bug reports

My app from iOS6 to iOS7 Label issue

i want to change iOS6 application to iOS7.(i.e)i want iOS7 compatibility. When i run my application in iOS7 simulator,view is moving up.
Can someone help me?
The full size of the iPhone Screen (non-retina, for simplicity sake, since that what we use with layout coordinates) is 320x480.
In iOS6 and previous, from a developer standpoint, the screen size was actually 320x460, with a 320x20 strip at the top for the status bar. In iOS6, the point x=0, y=0 translates to the iOS7 point of x=0,y=20.
This is because now the status bar is transparent an you can controller how that 320x20 strip at the top looks.
If you want to support both, you need to check which version of iOS they're using, and if they're using iOS7 or greater, you need to increment the origin.y by 20 pretty much everywhere.
Borrowed from this StackOverflow answer, here is how to programmatically determine which version of iOS is running:
NSString *version = [[UIDevice currentDevice] systemVersion];
int ver = [version intValue];
if (ver < 7) {
//iOS 6 work
} else {
//iOS 7 related work
}
Because by default viewcontroller have extended edges and it will go under top bar, set it to UIedgeRectNone then view will not go under the top bar.
self.edgesForExtendedLayout = UIRectEdgeNone;
Best way to support both iOS6 and iOS7 without much pain is to pack all your view controllers inside navigation controller (with navigation bar set to hidden if necessary).
This will allow to automatically and cleanly handle status bar behaviour changes.
People are nibbling around the correct answer, but haven't given it. I struggled with this for weeks, and finally figured out how to handle it correctly.
How to handle layout differences between iOS 6 and iOS 7 so you can support both without custom code:
The answer is different depending on whether you're using auto-layout or struts and springs.
For auto layout, you tie your top constraints to the "top layout guide", an imaginary line that starts at the content area of the window. It's under any status bar or navigation bar that's present, and moves up if either or both of those items are not shown.
For struts and strings based layout, IB has a mechanism that will let you adjust your view layout automatically.
Select your nib file/storyboard file.
Open the "File inspector" on the right side and look for an item titled "View as". Set that to "iOS 6.1 and earlier. This does several things. It makes your UI look like the app is running under iOS 6, and it makes the geometry work as if it's running under iOS 6.1 rules (the 0.0 point of your content view is under the status bar and your effective screen size is 20 points smaller when the status bar is shown.)
Next, select the views that are pinned to the top of your screen and choose the Size Inspector. (The tab in the utilities area that looks like a ruler). There is a new section of the size inspector called "iOS 6/7 deltas." This lets you specify changes to apply to the selected view when running in the "other" version of iOS than the one you specified above in the file inspector. Since we specified iOS 6, the current layout is using iOS 6 rules, so we want to specify the changes that are needed when running iOS 7 instead. If we had specified "View as iOS 7" in the file inspector, we'd be seeing an iOS 7 layout, and we'd be specifying changes to make when we run under iOS 6. You can do it either way. However, beware. If you have delta values (described below) and then switch this setting, IB moves stuff around on you in very confusing and destructive ways. Don't do that. Pick a value for the "View as" setting and stick with it for your entire app or you will get very confused and frustrated.
You want to make your navigation bars 20 points taller (They then automatically tint the status bar and adjust their layout so their titles and bar button items don't overlap the status bar.)
You also typically want to make views that are pinned to the top of the screen have a delta Y of 20 points to shift them down to make room for the status bar.
If a view is also pinned to the bottom of the screen so it's size adapts with the screen size, you'll probably also want a delta height of -20 pixels.
It takes some tinkering to get everything working right, but by setting your "iOS 6/7 delta" values correctly, you can create IB files that work correctly on both OS versions without any custom code.
If you DO have custom code to do things like tweak your layout for user interface orientation, though, things get really confusing.

iOS 6/7 20px difference using autolayout

I've got a background for the project that I am working on, which includes a 20px coloured bar for the top of an iOS 7 device.
This worked fine without autolayout, setting a 20px delta in storyboard. But now I can't do that, and I am stuck with constraints - which I cannot set on a per-OS basis.
Whatever I do, I seem to end up with the version on iOS 7 being 20px higher than on ios 6... Something I need to rectify, as I also have a bar under that status bar which is coloured for a navigation controller.
I've attached the background image - if I need to modify it to work with autolayout, I'm happy to do that.
There is a "top layout guide" object in your view hierarchy. If you build vertical constraints based on that, they pin to the top of the window if there is no status bar, or under the status bar otherwise. Use that.

Scaling entire iPad app to fit status bar

I've been searching SO and Google for a while now with no luck.
What I need to do, is in certain conditions, display a status bar at the top of my application.
When this bar shows, I need to shrink all the other content down so everything still fits on the screen.
I know I can use CGAffineTransformScale, however, I am not having any luck doing it globally for the entire app.
I'm sure I'm missing something obvious. Guess my lack of experience is showing.
Thanks
EDIT: The 'status' bar I'm referring to is NOT the standard iOS status bar. It is a custom status bar that appears only in certain conditions and sits at the top of the app.
I would check your autolayout settings on the first view you added to the controller - if you have them setup correctly then it should resize automatically.
If you use a UIViewController or any concrete subclass of that, its view should automatically adapt to whether or not the status bar is currently visible.
Now in case you use autoresizing masks, your UI should be fine. Same should apply if you use a UIScrollView.
Alternatively: In Interface Builder, select your view controller and on the attributes inspector turn off Layout: Wants Full Screen. Then, your layout will automatically adjust its size to make room for the navigation bar.

Resources