是否可以创建可用于不同 xib 的约束?所以当我决定改变时。边距在我的所有 View 中都会自动更改。
我正在考虑子类化NSLayoutConstraint
,但只能设置此类的常量属性,如果我想使用乘法器怎么办?
最佳答案
Is it possible to create constraint that can be used in different xibs ? So when I decide to change ie. a margin it'll change automatically in all my views.
不可以。一个给定的约束是一个引用其他特定对象的实际对象,所以你不能有一个单一的约束对象来管理多对 View 之间的关系。
I ws thinking about sublcassing NSLayoutConstraint but it's only possible to set constant property of this class and what if I want to use multiplier intead?
要更改multiplier
,您需要创建一个新约束来替换旧约束。似乎没有解决此要求的简单方法。
关于ios - xib 中的全局约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33082524/