Swiftpack.co - LudvigSahlin/Constraint as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
LudvigSahlin/Constraint
This package is used to programmatically add constraints. It works great with stack views.
.package(url: "https://github.com/LudvigSahlin/Constraint.git", from: "0.1.0")

Constraint

This package is used to programmatically add constraints. It works great with stack views.

Important:

  • This package adds some convenient extension functions to UIView so you can naturally add constraints directly from a view to another (see Usage).

Usage:

// - Stack Views -
buttonsHorizontalStackView = UIStackView(arrangedSubviews: [saveContainerView, infoContainerView, adminContainerView, UIView()])
buttonsHorizontalStackView.axis = .horizontal

stackView = UIStackView(arrangedSubviews: [
                                           givenNameContainerView,
                                           familyNameContainerView,
                                           plateNumberContainerView,
                                           submitContainerView,
                                           buttonsHorizontalStackView])
stackView.axis = .vertical
view.addSubview(stackView)

// - Constraints -
stackView.constrainTo(view.safeAreaLayoutGuide, .allBorders)

buttonsHorizontalStackView.constrainHeightTo(72)
saveBackgroundView.constrainTo(saveContainerView, [.top(16), .bottom(-16), .leading(16), .trailing])
infoBackgroundView.constrainTo(infoContainerView, [.top(16), .bottom(-16), .leading(8), .trailing])
adminBackgroundView.constrainTo(adminContainerView, [.top(16), .bottom(-16), .leading(8), .trailing])

submitContainerView.constrainHeightTo(72)
submitBackgroundView.constrainTo(submitContainerView, .allBorders(16))

License

The contents of this repository is licensed under the Apache License, version 2.0.

Contact

ludvigsahlin2@gmail.com

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.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

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