Skip to content

The lightweight to make AutoLayout with constraints

License

Notifications You must be signed in to change notification settings

levantAJ/TheConstraints

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CocoaPods CocoaPods Pod License Build Status

📱📐 The Constraints

The light weight to make constraints

Requirements

  • iOS 9.0 or later
  • Xcode 10.0 or later

Installation

There is a way to use TheConstraints in your project:

  • using CocoaPods

Installation with CocoaPods

pod 'TheConstraints', '1.5'

Build Project

At this point your workspace should build without error. If you are having problem, post to the Issue and the community can help you solve it.

How To Use

import TheConstraints

view.addSubview(subView)

Position:

subView.leading == view.leading
subView.trailing == view.trailing
subView.top == view.top - 100
subView.bottom == view.bottom + 100

Size:

subView.width == 50
subView.width == view.width + 100
subView.width == view.width * 2

subView.height == 100
subView.height == view.height - 200
subView.height == view.height / 2

Center:

subView.centerX == view.centerX + 100
subView.centerY == view.centerY - 200

subView.mid == view.mid // centerX & centerY

Edges:

subView.edges == view.edges // top & trailing & bottom & leading
subView.edges == inset(view.edges, 8) // as `UIEdgeInsets(top: 8, left: 8, bottom: -8, right: -8)` 
subView.edges == inset(view.edges, horizontal: 8) // as `UIEdgeInsets(top: 0, left: 8, bottom: 0, right: -8)` 
subView.edges == inset(view.edges, vertical: 4) // as `UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)`
subView.edges == inset(view.edges, horizontal: 8, vertical: 4) // as `UIEdgeInsets(top: 4, left: 8, bottom: -4, right: -8)`
subView.edges == inset(view.edges, insets: UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)) // as `UIEdgeInsets(top: 4, left: 8, bottom: -4, right: -8)`

Updates:

let bottomConstraint = subView.bottom == view.bottom
bottomConstraint.constant = 100

Author

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Licenses

All source code is licensed under the MIT License.