TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Andrzej Zuzak.
AZEasyAnchors is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'AZEasyAnchors'
Andrzej Zuzak, [email protected]
Firstly, we want to make childView
fill it's parentView
:
parentView.addSubview(childView)
childView.fillView(view: parentView)
Then, we want our childView
to be 20pt from parentView
top, 30pt from it's right, 0pt from it's left and for it to have height of 300:
parentView.addSubview(childView)
childView.position(top: parentView.topAnchor, topConstant: 20,
trailing: parentView.trailingAnchor, trailingConstant: 30,
leading: parentView.leadingAnchor)
childView.size(heightConstant: 300)
Next, we want to animate our constraints. We do it in a very simple way:
parentView.addSubview(childView)
let constraints = childView.position(top: parentView.topAnchor, topConstant: 20)
constraints[.top]?.constant += 10
UIView.animateWithDuration(0.5) {
self.view.layoutIfNeeded()
}
AZEasyAnchors is available under the MIT license. See the LICENSE file for more info.