Latest 0.6
Homepage https://github.com/andzuz/AZEasyAnchors
License MIT
Platforms ios 11.0
Frameworks UIKit
Authors

CI Status
Version
License
Platform

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

iPhone X

This library supports iPhone X safe-area layout guides. Expression:

childView.fillView(view: self.view)

automatically applies safe-area layout constraints to top, bottom, but also leading and trailing constraint (last two are needed for landscape orientation to be displayed properly). If you don’t want to use safe-area layout guides just include additional parameter in method call:

childView.fillView(view: self.view, useSafeArea: false)

License

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

Latest podspec

{
    "name": "AZEasyAnchors",
    "version": "0.6",
    "summary": "This library provides extensions to create pain-free constraints using layout anchors.",
    "description": "This library provides extensions to create pain-free constraints using layout anchors. It has UIView methods to position a view, give it width and height based on a constant or relative to the other view and center it in it's parent view.",
    "homepage": "https://github.com/andzuz/AZEasyAnchors",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "andzuz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/andzuz/AZEasyAnchors.git",
        "tag": "0.6"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source_files": "Classes/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This