测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布日期最后发布日期 | 2017年11月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Andrzej Zuzak 维护。
AZEasyAnchors 可以通过 CocoaPods 获取。要安装它,只需在您的 Podfile 中添加以下行:
pod 'AZEasyAnchors'
Andrzej Zuzak, [email protected]
首先,我们想让 childView
充满它的 parentView
parentView.addSubview(childView)
childView.fillView(view: parentView)
然后,我们想让我们的 childView
在 parentView
的顶部有 20pt,右部 30pt,左部 0pt,并且高度为 300
parentView.addSubview(childView)
childView.position(top: parentView.topAnchor, topConstant: 20,
trailing: parentView.trailingAnchor, trailingConstant: 30,
leading: parentView.leadingAnchor)
childView.size(heightConstant: 300)
接下来,我们想要动画化我们的约束。我们以非常简单的方式进行此操作
parentView.addSubview(childView)
let constraints = childView.position(top: parentView.topAnchor, topConstant: 20)
constraints[.top]?.constant += 10
UIView.animateWithDuration(0.5) {
self.view.layoutIfNeeded()
}
AZEasyAnchors 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。