A library for building autolayout constraints in a consistent and understandable way, with composition in mind.
You can add HSLayout to an Xcode project by adding it as a package dependency.
If you want to use HSLayout in a SwiftPM project, it's as simple as adding a
dependencies clause to your
dependencies: [ .package(url: "https://github.com/Hsieh-1989/HSLayout.git", from: "0.1.0") ]
Attaching a view to its superview with
view.translatesAutoresizingMaskIntoConstraints = false superview.addSubview(view) NSLayoutConstraint.activate([ view.topAnchor.constraint(equalTo: superview.topAnchor, constant: 0), view.leadingAnchor.constraint(equalTo: superview.leadingAnchor, constant: 0), view.bottomAnchor.constraint(equalTo: superview.bottomAnchor, constant: 0), view.trailingAnchor.constraint(equalTo: superview.trailingAnchor, constant: 0) ])
superview.addSubview(view, layout: .fit())
Constraining the center of a view to its superview with
NSLayoutConstraint.activate([ view.centerXAnchor.constraint(equalTo: superview.centerXAnchor, constant: 0) view.centerYAnchor.constraint(equalTo: superview.centerYAnchor, constant: 0) ])
view.constraints(to: superview, layout: .center)
|Last commit: 4 weeks ago|