Skip to content

An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.

Notifications You must be signed in to change notification settings

Kaakati/K-AutoLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

K-AutoLayout

An Autolayout Extension for iOS written in Swift 3

An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.

HOW TO USE:

Just copy the AutoLayout.swift file to your project.

Example

Add yourView as Subview

var yourView : UILabel = {
    let label = UILabel()
    label.text = "Your UILabel Text"
    label.textAlignment = .center
    label.translatesAutoresizingMaskIntoConstraints = false // Don't Forget to add this line.
    return label
}()

view.addSubview(yourView)

Assign AutoLayout as follow anchorToTop if you don't want to set margins:

yourView.anchorToTop(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor)
OR

Assign AutoLayout as follow anchorWithConstantsToTop if you want to set margins:

yourView.anchorWithConstantsToTop(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0)

If you want your view to connect to superview bottom edge set bottom: view.bottomAnchor

OR

To add a secondView below yourView set it's top: as yourView.bottomAnchor

secondView.anchorWithConstantsToTop(top: yourView.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0)

About

An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages