The light weight to make constraints
- iOS 9.0 or later
- Xcode 10.0 or later
There is a way to use TheConstraints in your project:
- using CocoaPods
pod 'TheConstraints', '1.5'
At this point your workspace should build without error. If you are having problem, post to the Issue and the community can help you solve it.
import TheConstraints
view.addSubview(subView)
subView.leading == view.leading
subView.trailing == view.trailing
subView.top == view.top - 100
subView.bottom == view.bottom + 100
subView.width == 50
subView.width == view.width + 100
subView.width == view.width * 2
subView.height == 100
subView.height == view.height - 200
subView.height == view.height / 2
subView.centerX == view.centerX + 100
subView.centerY == view.centerY - 200
subView.mid == view.mid // centerX & centerY
subView.edges == view.edges // top & trailing & bottom & leading
subView.edges == inset(view.edges, 8) // as `UIEdgeInsets(top: 8, left: 8, bottom: -8, right: -8)`
subView.edges == inset(view.edges, horizontal: 8) // as `UIEdgeInsets(top: 0, left: 8, bottom: 0, right: -8)`
subView.edges == inset(view.edges, vertical: 4) // as `UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)`
subView.edges == inset(view.edges, horizontal: 8, vertical: 4) // as `UIEdgeInsets(top: 4, left: 8, bottom: -4, right: -8)`
subView.edges == inset(view.edges, insets: UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)) // as `UIEdgeInsets(top: 4, left: 8, bottom: -4, right: -8)`
let bottomConstraint = subView.bottom == view.bottom
bottomConstraint.constant = 100
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
All source code is licensed under the MIT License.