Latest 0.2.0
License MIT
Platforms ios 9.0
Frameworks UIKit


Constraints have been hard to create in code for a long time. The default UIKit way would be the following:

let viewA = UIView()
let viewB = UIView()

# Before iOS 9

let constraint = NSLayoutConstraint(item: viewA, attribute: .top, relatedBy: .equal, toItem: viewB, attribute: .bottom, multiplier: 1, constant: 0)

# After iOS 9

let constraint = viewA.topAnchor.constraint(equalTo: viewB.bottomAnchor)

While layout anchors made the creation a lot easier, it is still not as intuitive as it could be. Introducing: SimpleConstraints.

With SimpleConstraints, you can create NSLayoutConstraints like mathematical equations as in the following:

let viewA = UIView()
let viewB = UIView()

let constraint = viewA.heightAnchor * 5 - 3 <= viewB.widthAnchor + 25

With many operator overloads, some UIView-extensions for most commonly used constraints and also NSLayoutConstraint-extensions,
SimpleConstraints is designed to simplify the handling of UI without the need of storyboards or .xib-files.


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

pod 'SimpleConstraints'




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

Latest podspec

    "name": "SimpleConstraints",
    "version": "0.2.0",
    "summary": "SimpleConstraints makes it easier and more intuitive to create NSLayoutConstraints.",
    "description": "SimpleConstraints allows you to create NSLayoutConstraints using mathematical equations. This makes it a lot more intuitive to create layout constraints.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "pauljohanneskraft": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.2.0"
    "platforms": {
        "ios": "9.0"
    "swift_version": "4.2",
    "source_files": "SimpleConstraints/Classes/**/*",
    "frameworks": "UIKit"

Pin It on Pinterest

Share This