Laly is an lightweight framework ment to reduce the ammount of code used while using NSLayoutAnchor or NSLayoutConstraint. It's easy to learn, read/write and debug.
The current release of Laly supports the following versions of iOS and OS X:
Andrei-Popilian/Laly
project to your Cartfile.github "Andrei-Popilian/Laly" == 1.3.0
Run carthage update
, then follow the additional steps required to add the framework into your project.
Import the Laly framework/module.
import Laly
Xcode -> File -> Swift Packages -> Add Package Dependecy...
Add package dependecy URL: https://github.com/Andrei-Popilian/Laly.git
Use version 1.3.0 +
Import the Laly framework/module.
import Laly
That's it - now go write some beautiful Auto Layout code!
NSLayoutConstraint.activate([
someView.widthAnchor.constraint(equalToConstant: 70),
someView.heightAnchor.constraint(equalToConstant: 15),
someView.centerXAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerXAnchor),
someView.centerYAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerYAnchor),
])
==
someView.laly.size(.height(15), .width(70))
someView.laly.center(to: self.view.safeAreaLayoutGuide, on: .x, .y)
OR
NSLayoutConstraint.activate([
someView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 20),
someView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: -20),
someView.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 20),
someView.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: -20),
])
==
someView.laly.edges(to: self.view.safeAreaLayoutGuide, ofIdentation: 20)
OR
NSLayoutConstraint.activate([
someView.topAnchor.constraint(lessThanOrEqualTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 20),
someView.trailingAnchor.constraint(greaterThanOrEqualTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: -15),
someView.leadingAnchor.constraint(greaterThanOrEqualTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 15),
someView.bottomAnchor.constraint(greaterThanOrEqualTo: self.view.safeAreaLayoutGuide.topAnchor, constant: -20),
])
==
someView.laly.edges(to: self.view.safeAreaLayoutGuide, of: .top(<=20), .trail(>=(-15)), .lead(>=15), .bot(>=(-20)))
OR
NSLayoutConstraint.activate([
someView.widthAnchor.constraint(equalTo: self.view.widthAnchor),
someView.heightAnchor.constraint(equalTo: self.view.heightAnchor),
])
==
someView.laly.size(of: self.view)
OR
NSLayoutConstraint.activate([
someView.topAnchor.constraint(equalTo: secondView.topAnchor, constant: 20),
someView.bottomAnchor.constraint(equalTo: secondView.topAnchor, constant: 100)
])
==
someView.laly.edges(to: secondView, relations: (.top, to: .topBy(10)), (.bot, to: .topBy(100)))
For more please check Laly's documentation inside Xcode
NOTE: all the constraints generated by Laly are already activated, to deactivate them call .deactivated() on each one or on an array containing multiple constraints
let constraints = someView.laly.edges(to: self.view.safeAreaLayoutGuide, of: .top(<=20), .trail(>=(-15)), .lead(>=15), .bot(>=(-20)))
let deactivatedConstraints = constraints.deactivated()
Please open a new Issue here if you run into a problem specific to Laly, have a feature request, or want to share a comment. Note that general Auto Layout questions should be asked on Stack Overflow.
Pull requests are encouraged and greatly appreciated! Please try to maintain consistency with the existing code style. If you're considering taking on significant changes or additions to the project, please communicate in advance by opening a new Issue. This allows everyone to get onboard with upcoming changes, ensures that changes align with the project's design philosophy, and avoids duplicated work.
link |
Stars: 1 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics