๐ Simple autolayout wrapper
Add pod to Podfile
pod 'K1ngLayout', :git => 'https://github.com/bestK1ngArthur/K1ngLayout'
Add package to dependencies
.package(url: "https://github.com/bestK1ngArthur/K1ngLayout", from: "0.0.2"),
Documentation is available by link.
// With Auto Layout
let constraints = [
view.topAnchor.constraint(equalTo: superview.topAnchor, constant: 8),
view.leftAnchor.constraint(equalTo: superview.leftAnchor, constant: 16)
]
NSLayoutConstraint.activate(constraints)
// With K1ngLayout
let constraints = [
view.top.equal(to: superview.top, constant: 8),
view.left.equal(to: superview.left, constant: 16)
]
view.activate(constraints)
// With Auto Layout
let constraints = [
view.topAnchor.constraint(equalTo: superview.topAnchor),
view.bottomAnchor.constraint(equalTo: superview.bottomAnchor),
view.leftAnchor.constraint(equalTo: superview.leftAnchor),
view.rightAnchor.constraint(equalTo: superview.rightAnchor)
]
NSLayoutConstraint.activate(constraints)
// With K1ngLayout
view.activate(
view.pinEqualEdges(to: superview)
)
// With Auto Layout
let constraints = [
view.leftAnchor.constraint(equalTo: superview.leftAnchor, constant: 16),
view.rightAnchor.constraint(equalTo: superview.rightAnchor, constant: -16)
]
NSLayoutConstraint.activate(constraints)
// With K1ngLayout
view.activate(
view.pinEqualEdges(to: superview, insets: .horizontal(16))
)