Update 2017-08-25: This bug appears to be fixed in Xcode 9, beta 6.
On Xcode 9, when compiling to iOS 10; views nested in root view with “Preserve Superview Margins” enabled, have an incorrect margin of 8px.
I’ve filed a radar with Apple:
Xcode 9 (beta 5) generates incorrect margins when building for iOS 10 with “Preserves Superview Margins” enabled in Interface Builder.
The same code works correct on Xcode 9 + iOS 11, and also correct on Xcode 8 + iOS 10.
Steps to Reproduce
In Xcode 9, beta 5 / iOS 10:
- Create a “Wrapper View” in interface builder directly under root view of view controller
- Pin edges to superview edges on Wrapper View
- Enable “Preserve Superview Margins” on Wrapper View
- Add subview to Wrapper View that is pinned to the Wrapper View layout margins
Left and right margins should be 16 or 20, depending on device.
Left and right margins are always 8.
Does not occur when building with Xcode 8 (for iOS 10) or Xcode 9 (for iOS 11)
Setting explicit layout margins instead of using “Preserve Superview Margins” only works after rotating screen.
But this is probably an unrelated iOS 10 bug, as this also happens in Xcode 8.