Skip to content

kabyshev/AiryLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AiryLayout 💨

A simple Auto Layout wrapper - write readable layouts!

Language: Swift 5.0

Simple Example:

label.top(10).left(5).right(20).bottom()

Pins edge to edge and with inset:

tableView.pin()
scrollView.pin(10)

Different components:

label.topAnchor ~ customView.bottomAnchor + 7.0
label.leftAnchor ~ customView.leftAnchor + 15.0
label.rightAnchor ~ customView.rightAnchor - 4.0

Equals more compact API:

label.pin([.top(7): .bottom, .left(15): .left, .right(4): .right], to: customView)

Combinations:

@Layouting var switcher = UISwitch()
@Layouting var label = UILabel()
@Layouting var button = UIButton()

switcher.centerY().left(8)

label.centerY().centerX()

button
   .left(to: .right(20), of: label)
   .top(to: switcher)
   .right(24)

Enabling safe area API

collectionView.left().right().safeArea { $0.top().bottom(10) }

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Just add AiryLayout in your Package.swift as a dependency:

dependencies: [
    .package(url: "https://github.com/kabyshev/AiryLayout.git", .upToNextMajor(from: "1.0.0"))
]

Manually

If you prefer not to use SPM, you can integrate AiryLayout into your project manually: add Sources folder to your project.

About

A simple Auto Layout wrapper - write readable layouts!

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages