AZEasyAnchors 0.6

AZEasyAnchors 0.6

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布日期2017年11月
SwiftSwift 版本4.0
SPM支持 SPM

Andrzej Zuzak 维护。



  • 作者:
  • andzuz




需求

安装

AZEasyAnchors 可以通过 CocoaPods 获取。要安装它,只需在您的 Podfile 中添加以下行:

pod 'AZEasyAnchors'

作者

Andrzej Zuzak, [email protected]

用法

快速入门

首先,我们想让 childView 充满它的 parentView

parentView.addSubview(childView)
childView.fillView(view: parentView)

然后,我们想让我们的 childViewparentView 的顶部有 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 文件。