ios - xib 中的全局约束

标签 ios xcode interface-builder

是否可以创建可用于不同 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/

相关文章:

ios - 仅使用 iPhone 模拟器更好地测试 GPS 代码的巧妙方法?

ios - UIPopoverController 内的导航

ios - 下载 Xcode 9(或 9.1 Beta 版)

ios - 当键盘出现时,如何阻止 tableView 外部的标题消失

ios - 我们可以在 Apple Developer 帐户中禁用 iCloud App 服务吗?

javascript - 在 UIWebView 上定义事件

ios - Xcode 无法添加静态库

ios - 无法实例化名为 IBNSLayoutConstraint 的类

objective-c - 寻找有关界面组件自定义绘图的信息(Cocoa)

xcode - Monodevelop 2.8、XCode 3.2.6、界面生成器 : Outlets and Actions