Constraints and margins in xcode 6, margins revealing whitespace after snap

允我心安 提交于 2019-12-24 11:24:30

问题


I'm trying to constrain a couple of views within a controller. I understand how to set spacing between views, and width/height for each view. I'm a little unsure about dynamic height and width, I'm assuming that it's the margin-locks duty to adjust the weight appropriately. Advice on this would be much appreciated.

Anyways, I'm trying to set a "Trailing Space to: Superview" constraint, which automatically sets to -16. See photo:

As you can see, I've selected margins for left right and top of view.

But once I launch the app in iPhone 6 Plus, the margins set are about -20 required. You can see my problem. Here's another photo, the view I'm talking about is green (you can see the whitespace on either side of it):


回答1:


The margins are a gap on the left and right to make things look neat. Due to the width of different devices, different devices have different sized margins. If you want to constrain your view to the edge you need to turn the margins off and set the constraints to 0. The margin on the 6 plus is 20, and I believe that the margins on the other devices are 16.

If there is no width constraint the view will stretch if you have a left and right margin.




回答2:


Check out the constrain to margins checkbox and set the values to 0

Please refer this posts about xcode

What is "Constrain to margin" in Storyboard in Xcode 6

Attribute Unavailable warning on iOS versions prior to 8.0



来源:https://stackoverflow.com/questions/26107159/constraints-and-margins-in-xcode-6-margins-revealing-whitespace-after-snap

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