一个轻量级的 Swift 库,为 UIKit 提供便捷的 Auto Layout 辅助方法。
translatesAutoresizingMaskIntoConstraints
您可以使用 Swift Package Manager 将 AutoLayout
添加到您的项目中。在 Xcode 中:
https://github.com/componentskit/AutoLayout
import AutoLayout
let containerView = UIView()
let subView = UIView()
containerView.addSubview(subView)
subView.allEdges(16) // Adds 16 padding on all sides
subView.centerHorizontally()
subView.centerVertically()
subView.width(100)
subView.height(50)
let firstView = UIView()
let secondView = UIView()
containerView.addSubview(firstView)
containerView.addSubview(secondView)
secondView.after(firstView, padding: 8)
subView.horizontally(20)
该项目基于 MIT 许可证。有关详细信息,请参见 LICENSE 文件。
欢迎贡献!请提出 issue 或提交 pull request。