Create FUNDING.yml
This repository provides some convenience methods for creating constraints.
view.pin(.edges) view.pin(.leading) view.pin(.edges(.horizontal), 16) view.pin(edges(.top, .bottom), 10, to: safeAreaLayoutGuide) view.pin(edges: [.top: 10, .horizontal: 5], to: safeAreaLayoutGuide) // pin view after/before another view rightView.pin(to: .trailing, of: leftView, options: .offset(10)) view.pin(.center, 10) view.pin([.size: 100, .centerY: 10, .top: 20, .edges(.horizontal): 10])
view.pin(.top, to: .centerY, of: anotherView)
view.pin(aspectRatio: 2 / 3)
with options
view.pin(.edges, 10, options: .priority(.required))
.priority(300)
.offset(10)
.multiplier(2)
.relation(.greaterThanOrEqual)
.greaterThanOrEqual
.lessThanOrEqual
.inactive
.activated(false)
.update
.translatesAutoresizingMask
translatesAutoresizingMaskIntoConstraints
.safeArea
safeAreaLayoutGuide
superview
view .pin(.edges(.horizontal), 10) .pin(to: .bottom, of: anotherView.pin(.height, 50), options: .offset(20)) .pin(.size, 100)
PartialRangeThrough
PartialRangeFrom
view.pin(.bottom, 10..., with: .safeArea) view.pin(to: .bottom, of: anotherView, options: .offset(...10))
Constraints
Create a Package.swift file.
Package.swift
// swift-tools-version:5.7 import PackageDescription let package = Package( name: "SomeProject", dependencies: [ .package(url: "https://github.com/dankinsoid/VDPin.git", from: "1.7.0") ], targets: [ .target(name: "SomeProject", dependencies: ["VDPin"]) ] )
$ swift build
Add the following line to your Podfile:
pod 'VDPin'
and run pod update from the podfile directory first.
pod update
dankinsoid, voidilov@gmail.com
VDPin is available under the MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
VDPin
Description
This repository provides some convenience methods for creating constraints.
Usage
with options
parameter. options:.priority(300)
: set the priority of the constraint.offset(10)
: set the offset of the constraint.multiplier(2)
: set the multiplier of the constraint.relation(.greaterThanOrEqual)
,.greaterThanOrEqual
,.lessThanOrEqual
: set the relation of the constraint.inactive
,.activated(false)
: set the active state of the constraint.update
: update the constraint if it already exists.translatesAutoresizingMask
: don’t changetranslatesAutoresizingMaskIntoConstraints
property.safeArea
: usesafeAreaLayoutGuide
instead ofsuperview
as default second itemPartialRangeThrough
andPartialRangeFrom
for offset valueConstraints
object, that can be used for updating constraints.Installation
Create a
Package.swift
file.Add the following line to your Podfile:
and run
pod update
from the podfile directory first.Author
dankinsoid, voidilov@gmail.com
License
VDPin is available under the MIT license. See the LICENSE file for more info.