iOS 7与iOS 8约束的大小不同 [英] iOS 7 vs iOS 8 Constraints differ in sizes

查看:139
本文介绍了iOS 7与iOS 8约束的大小不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在界面生成器中使用自动布局和约束时,我注意到当我运行iOS7与iOS8模拟器时,我得到的结果相同。

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.

例如,我在一个8pts的UIButton上设置了一个非常简单的尾随约束。在iOS7和iOS8模拟器上运行时,这些8pts的位置看起来非常不同。 iOS8模拟器似乎为约束添加了几点。好像需要为Constraint Delta提供功能...

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...

任何想法为什么约束在iOS7和iOS8上表现不同?

Any ideas why constraints behave different on iOS7 vs iOS8?



推荐答案

原因是iOS 8具有布局边距而iOS 7没有。您已经在标签边缘和超级视图的边距之间进行了约束 - 但在iOS 7中没有边距。因此,为了与两者兼容,运行时必须执行某事。所以它在iOS 7中将边距视为零,这是因为它们根本不存在。

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.

这篇关于iOS 7与iOS 8约束的大小不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆