JFLayout 0.0.3

JFLayout 0.0.3

hx 维护。



JFLayout 0.0.3

  • hxwxww

JFLayout

使用 Auto Layout 的简单方式

使用函数

redView.layout {
    $0.topAnchor.equal(to: view.safeAreaLayoutGuide.topAnchor, constant: 30)
    $0.leadingAnchor.equal(to: view.leadingAnchor, constant: 30)
    $0.heightAnchor.equal(to: view.heightAnchor, multiplier: 0.5, constant: 30)
}

blueView.layout {
    $0.topAnchor.equal(to: redView.topAnchor, constant: 30)
    $0.leadingAnchor.equal(to: redView.trailingAnchor, constant: 30)
    $0.widthAnchor.equal(to: redView.widthAnchor, multiplier: 0.5)
    $0.heightAnchor.equal(to: redView.heightAnchor, multiplier: 0.5, constant: 30)
}

使用运算符

redView.layout {
    $0.topAnchor == view.safeAreaLayoutGuide.topAnchor + 30
    $0.leadingAnchor == view.leadingAnchor + 30
    $0.heightAnchor == view.heightAnchor * 0.5 + 30
}

blueView.layout {
    $0.topAnchor == redView.topAnchor + 30
    $0.leadingAnchor == redView.trailingAnchor + 30
    $0.widthAnchor == redView.widthAnchor * 0.5
    $0.heightAnchor == redView.heightAnchor * 0.5 + 30
}

更新约束

redView.layoutConstraints[1].constant = redViewLeadingOffset