Swiftpack.co -  kean/Stacks as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
kean/Stacks
A micro UIStackView convenience API inspired by SwiftUI
.package(url: "https://github.com/kean/Stacks.git", from: "0.1.2")

Stacks

A micro UIStackView convenience API inspired by SwiftUI.

let stack: UIView = .hStack(alignment: .center, margins: .all(16), [
    .vStack(spacing: 8, [
        titleLabel,
        subtitleLabel
    ]),
    .spacer(minLength: 16),
    star
])
  • Concise syntax inspired by SwiftUI
  • Your code matches the created view hierarchy
  • Spacers automatically adjust to the stack view axis
  • Margins automatically enable isLayoutMarginsRelativeArrangement

Screen Shot 2021-04-16 at 13 36 02

UIEdgeInsets extensions are not included.

extension UIEdgeInsets {
    static func all(_ value: CGFloat) -> UIEdgeInsets {
        UIEdgeInsets(top: value, left: value, bottom: value, right: value)
    }

    init(v: CGFloat, h: CGFloat) {
        self = UIEdgeInsets(top: v, left: h, bottom: v, right: h)
    }
}

For more layout goodness, check out Align.

GitHub

link
Stars: 57
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