测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017 年 10 月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由Marc Baldwin维护。
创建支持所有设备和方向的布局。
Alto 仍在开发中。一个非常稳定的版本将会很快发布。star 或者 watch 以跟踪进度 :)
Alto 旨在成为
// Align the center of titleLabel 40px from the top of the container
titleLabel.set(.centerY, .equalTo, containerView, .top + 40)
// Align the centers of titleLabel and subtitleLabel to the container
[titleLabel, subtitleLabel].set(.centerX, .equalTo, containerView, .centerX)
此代码可以编译但是会导致崩溃
NSLayoutConstraint(item: titleLabel, attribute: .height, relatedBy: .equal, toItem:
containerView, attribute: .centerX, multiplier: 1.0, constant: 0.0)
此代码无法编译 :)
titleLabel.set(.height, .equalTo, containerView, .centerX) <-- Error
查看示例和图表 即将推出
例如:.center
,.size
,.edges
,.topLeft
titleLabel.set(.center, .equalTo, containerView, .center)
titleLabel.set(.topLeft, .equalTo, containerView, .bottomRight)
titleLabel.set(.edges, .equalTo, containerView, .edges - 5)
将相同的约束应用于多个视图
[titleLabel, subtitleLabel].set(.center, .equalTo, containerView, .center)
使用约束创建 UIStackView
风格的布局
views.stack(.vertically, margin: 20)
views.stack(.vertically, in: containerView, margin: 20)
titleLabel.set(.width, .greaterThanOrEqualTo, containerView, .width, priority: .low)