Matthew R.
Matthew R.

Reputation: 625

How can I make sure my iOS 7 layouts look the same on iOS 6?

I understand that the UI elements will look different, and that is not what I am worried about. I created a simple app in Xcode 5 that just displays a label right under the status bar. In iOS 7 this looks fine. However, when I run the app on an iOS 6 device, the label appears too far down from the status bar. I know that in iOS 7, y=0 is the top of the screen instead of the bottom of the status bar, so I understand why this is happening, but I can't figure out how to fix it. I have seen solutions using self.edgesForExtendedLayout = UIRectEdgeNone, and others that use the deltas in Interface Builder when Autolayout is turned off, however none of these have worked for me.

How can I fix this (while still using Autolayout)? There must be a better way than just subtracting 20 px from the view's position if the system version is iOS 6.1 or earlier.

Upvotes: 2

Views: 1347

Answers (2)

jrc
jrc

Reputation: 21881

I think the answer you're looking for is in this tech note. (In short: apply a Vertical Space Constraint anchored to the Top Layout Guide of your view controller.)

Technical Q&A QA1797: Preventing the Status Bar from Covering Your Views https://developer.apple.com/library/ios/qa/qa1797/_index.html

Upvotes: 2

Alexis C.
Alexis C.

Reputation: 4918

You can try using the iOS6/7 deltas on your UIViews in your nib files. It's located in the size inspector of your UIView.

enter image description here

Upvotes: 2

Related Questions