CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

AZEasyAnchors 0.6

AZEasyAnchors 0.6

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Andrzej Zuzak.



  • By
  • andzuz




Requirements

Installation

AZEasyAnchors is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'AZEasyAnchors'

Author

Andrzej Zuzak, [email protected]

Usage

Quick start

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()
}

License

AZEasyAnchors is available under the MIT license. See the LICENSE file for more info.