约束运算符
用法
使用简单表达式创建约束
view1.ignoreAutoresizingMask()
view1.centerX =| view2.centerX + 10
view1.centerY =| 15
view1.width <=| 200
view1.width >=| 100
//or
view1.width =| 100...200
view1.height =| view2.height / 2 + 20
...
view.width =| 100
view.width =| 200 //automatically replaces previuos width constraint
...
view1.height.priority(.defaultLow) =| 0
...
view1.height.priority(900) =| 10
...
let constraint: NSLayoutConstraint = view1.height.deactivated =| 200
...
view1.height =| view1.superview
view1.centerX =| view2
...
[view1, view2].ignoreAutoresizingMask()
[view1, view2].height =| 200
view1[.centerX, .centerY] =| 0
view1.edges(.vertical) =| 0
...
Axis.vertical =| [10, view1, 0..., view2.fixed(200), 0...5, view3.centerY, 10]
...
view1.top =| view1.leading //compile error, you cannot combine incompatible attributes
支持的操作符:=|
,<=|
,>=|
每个操作符都返回一个 NSLayoutConstraint
实例,其 isActive
属性设置为 true
。
安装
ConstraintsOperators 通过 CocoaPods 提供使用。要安装
它,只需将以下行添加到您的Podfile中
pod 'ConstraintsOperators'
作者
Voidilov,[email protected]
许可证
ConstraintsOperators 在MIT许可证下提供。有关更多信息,请参阅LICENSE文件。