Alto 0.0.5

Alto 0.0.5

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017 年 10 月
SwiftSwift 版本4.0
SPM支持 SPM

Marc Baldwin维护。



Alto 0.0.5

  • marcbaldwin

创建支持所有设备和方向的布局。

开发中

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

快速且简单

  1. 小的 API
  • 便捷属性以减少所需的代码,请参见功能
  • 没有操作符重载,这可能会增加编译时间

完善的文档

查看示例和图表 即将推出

功能

额外的属性

例如:.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)

待办事项列表

  1. 大小类
  2. 布局指南支持

资源