iOS 7 vs iOS 8 Constraints differ in sizes

∥☆過路亽.° 提交于 2019-12-10 21:25:41

问题


While working with Auto Layout and Constraints in the Interface Builder, I noticed that I am getting different results with the same constraints when I run iOS7 vs iOS8 simulator.

For example, I have a very simple Trailing Constraint set on a UIButton of 8pts. These 8pts look very different in placement when running on iOS7 vs iOS8 simulator. iOS8 simulator seems to add a few points to the constraint. It's as if there needs to be functionality for Constraint Delta's...

Any ideas why constraints behave different on iOS7 vs iOS8?


回答1:


The reason is that iOS 8 has layout margins and iOS 7 does not. You have made your constraints between the edge of the label and the margin of the superview — but in iOS 7 there are no margins. Thus, in order to be compatible with both, the runtime must do something. So it treats the margins as zero in iOS 7, which is what they are because they don't exist at all.



来源:https://stackoverflow.com/questions/27695758/ios-7-vs-ios-8-constraints-differ-in-sizes

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