Xcode 6 beta 7: storyboard adds extra space on right and left sides

五迷三道 提交于 2019-12-28 08:07:24

问题


When I add subview to root ViewController's view, and with auto layout setup leadingSpace,trailingSpace,topSpace and bottomSpace to zero, there are appear some extra spaces on left and right sides (so if I print subview's frame its origin will be 16 and size less on 32 than should be). So actually we get that leading and trailing spaces are not zeros...

As you can see on picture leading space - zero, but origin.x = 16

Earlier I wasn't working hard with auto layout, so my question is: Is it a bug of new Xcode or a feature?

P.S. All frames and constraints updated.


回答1:


iOS 8 adds the concept of “content margins” to UIView. The “What's New in Cocoa Touch” video from WWDC 2014 discusses content margins (under the title “Adaptive Margins”) starting at about 12m30s.

The default margins are 8 points on each side. Each end of a layout constraint can be relative to a view's margin instead of to the view's true edge (use File > Open Quickly to go to the definition of NSLayoutAttribute to see the possibilities).

Your constraint is “relative to margin”. When you create the constraint with the “Add New Constraints” popover, you can choose whether it's margin-relative or not:

It always defaults to margin-relative; you have to turn the checkbox off every time you add constraints if you don't want them to be margin-relative.

You can't change whether a constraint is margin-relative in the quick-edit popover of your screen shot. Instead, double-click the constraint to bring up its full Attributes inspector. There, you can use the popup menus to select, for each end of the constraint, whether it's margin-relative or not:



来源:https://stackoverflow.com/questions/25701979/xcode-6-beta-7-storyboard-adds-extra-space-on-right-and-left-sides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!