// Add body (bodyView fill view)
view.addBody(bodyView)
// Add body with safe area
view.addBody(bodyView, safe: true)
// Add body with insets 15
view.addBody(bodyView, insets: .all(15))
// Add body with horizontal insets 15
view.addBody(bodyView, insets: .horizontal(15))
Priority
// Set priority for each constraint
titleLabel.pin
.start().priority(.defaultHeight)
.end().priority(.defaultLow)
// Set priority for all constraints
titleLabel.pin.start().end().priorityForAll(.defaultHeight)
Access to NSLayoutConstraint
let start = titleLabel.pin.start().constraints.last
start.constant = 30
start.isActive = true
Pin
📌 A tiny library that makes working with AutoLayout easier.
A library for those who don’t want to use big libraries like SnapKit, but the standard NSLayoutConstraint creation seems too verbose.
Example with Pin 😸
Original code
Example without Pin 🙀
Methods
Activate and deactivate
Activation array of constraints is more efficient than activating each constraint individually.
Safe area
Body
Priority
Access to NSLayoutConstraint
Extensions
You can add own extensions:
Right to left languages
Methods
start(), end(), after(), before()
support rtl languages by default. If you want to force direction then use:Swift Package Manager