Skip to content

Repository files navigation

Meet JustLayout

JustLayout

AuthorEMailMIT
VersionPlatformsSwift
Build PassingCocoapodsCarthageSPM

🏵 Introduction

JustLayout is an elegant Auto Layout sugar for iOS and tvOS.

📋 Requirements

TypeRequirement

Platform

iOS

8.0+

macOS

N/A

tvOS

10.2

watchOS

N/A

Linux

N/A

IDE

Xcode

10.2+

Language

Swift

5+

📲 Installation

CocoaPods

JustLayout is available on CocoaPods.

use_frameworks!pod'JustLayout'# for DSL usage:#pod 'JustLayout/DSL

Manually

Copy all files in the JustLayout directory into your project.

🛌 Dependency

N/A

❤️ Contribution

You are welcome to fork and submit pull requests.

🔖 License

JustLayout is open-sourced software, licensed under the MIT license.

🔫 Usage

import JustLayout

Visually

func visually(){
view.layout(100,|-topView-|~80,8,|-centerView-(>=100)-|~80,"",
|bottomView| ~80,0)}

Chainable

func chainable(){
centerView.centerInContainer().width(100).aspectratio(followHeight:100%)
topView.left(centerView,-20).top(centerView,-20).size(centerView)
bottomView.left(centerView,20).top(centerView,20).size(centerView)}
AppIcon_480.png

Operator-Based

func operatorBased(){
bottomView.centerXAttribute == view.centerXAttribute
bottomView.centerYAttribute == view.centerYAttribute
bottomView.widthAttribute ==80
bottomView.heightAttribute == bottomView.widthAttribute
centerView.rightAttribute == bottomView.centerXAttribute
centerView.topAttribute == bottomView.centerYAttribute
centerView.widthAttribute == bottomView.widthAttribute
centerView.heightAttribute == bottomView.heightAttribute
topView.leftAttribute == centerView.rightAttribute
topView.topAttribute == centerView.topAttribute
topView.widthAttribute ==50% centerView.widthAttribute
topView.heightAttribute == centerView.heightAttribute
}

The Operator-Based layout is now chainable after version 1.4.0. For example:

someView.following(leftView).below(topView).size(centerView)
someView.leftAttribute == leftView.rightAttribute
someView.topAttribute == topView.bottomAttribute
someView.widthAttribute == centerView.widthAttribute
someView.heightAttribute == centerView.heightAttribute

DSL

After version 1.5.0 you can now use the JustLayoutDSL:

centerView.just.centerInContainer().width(100).aspectratio(100%)
topView.just.left(centerView,-20).top(centerView,-20).size(centerView)
bottomView.just.left(centerView,20).top(centerView,20).size(centerView)
Important

Please add pod 'JustLayout/DSL' to your `Podfile first.


Made with [heart] by Elias Abel.

About

🤥 Sugar for Auto Layout. Generate pure native NSLayoutConstraint.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages