Swiftpack.co -  janodev/autolayout as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
janodev/autolayout
Autolayout library
.package(url: "https://github.com/janodev/autolayout.git", from: "1.0.0")

Swift

Autolayout library.

Installation

.package(url: "https://github.com/j4n0/autolayout.git", from: "1.0.0"),

Usage

view.al.pin()
view.al.pinToLayoutMargins()
view.al.pinToSafeArea()
view.al.pinToReadableContent()

view.al.pin(sides: [.leading, .trailing])
view.al.pinToLayoutMargins(sides: [.top, .bottom])
view.al.pinToSafeArea(sides: [.leading, .top, .trailing])
view.al.pinToReadableContent(sides: [.top])

view.al.set(width: 0)
view.al.set(height: 0, priority: .defaultHigh)
view.al.set(size: CGSize.zero)

view.al.center()
view.al.centerX()
view.al.centerY()

view.al.center(to: view2)
view.al.centerX(to: view2)
view.al.centerY(to: view2)

// Enumerate all non nil views and apply the following Visual Format Language
view.al.applyVFL([
    "H:[handle(36)]",
    "V:[handle(5)]"
])

All elements are contained in the 'al' namespace to avoid polluting the view class.

If you are looking for layout libraries Align is more expressive BUT, if Apple breaks it tomorrow I don’t want to depend on a third party fixing it or waste time myself. Better to make it simple and repetitive, than adding convoluted indirections and lose control.

GitHub

link
Stars: 0
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API