Skip to content
/ Constren Public

Make trains of constraints with a clean style!

License

Notifications You must be signed in to change notification settings

dorvk/Constren

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT Constren Cocoapods

Constren πŸš‚.πŸšƒ.πŸš‹

Make trains of constraints with style!

button.constren
    .centerY()
    .lead(spacing: 16)
    .trail(image.leadingAnchor, spacing: 64)    
    .height(100, relation: .greaterThan)

Constren is an easy to use layout tool for UIKit

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 4.0+

Installation

Cocoapods

To add Constren into your project using CocoaPods, add it in your Podfile:

pod 'Constren', :git => 'https://github.com/dorvk/Constren.git'

Carthage

To add Constren into your project using Carthage, specify it in your Cartfile:

github "dorvk/Constren"

Swift Package Manager

To add Constren into your project using Swift Package Manager, add following into your Package.swift file,

dependencies: [ .package(url: "https://github.com/dorvk/Constren.git", .branch("master")) ]

Manually

Add the Sources folder into your project.

Example

import Constren

let imageView = UIImageView()

view.addSubview(imageView)

imageView.constren
    .top()                                   // default is equalToSuperview with 0 spacing
    .lead(spacing: 16)                       // you can add spacing
    .trail(label.leadingAnchor, spacing: 16) 
    .height(100, relation: .greaterThan)     // supports lessThan or greaterThan, default is equalTo
    
var constraint = imageView.constren
                    .width(50)
                    .asNSLayoutConstraint
                    
constraint?.constant = 100                   // supports constant updating 

tableView.constren.fill()                                  // shortcuts

collectionView.constren.fill(lead: 16, bot: 32)

titleLabel.constren
    .horizontalFill(lead: 16)
    .centerY(spacing: 16)
                    
imageView.constren
    .centered(x: 16)
    .squared(250)

About

Make trains of constraints with a clean style!

Resources

License

Stars

Watchers

Forks

Packages

No packages published