Swiftpack.co - Package - Andrei-Popilian/Laly


Platform iOS Support Swift Carthage Swift PM License

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.

Table of Contents

  1. Compatibility
  2. Carthage Support
  3. Swift Package Manager Support
  4. Usage examples
  5. Problems, Suggestions, Pull Requests?


The current release of Laly supports the following versions of iOS and OS X:

  • Xcode
    • Language Support: Swift (5.1)
    • Fully Compatible With: Xcode 10.0+
  • iOS
    • Fully Compatible With: iOS 9.0+

Using Carthage

  1. Add the Andrei-Popilian/Laly project to your Cartfile.
github "Andrei-Popilian/Laly" == 1.3.0
  1. Run carthage update, then follow the additional steps required to add the framework into your project.

  2. Import the Laly framework/module.

  • Swift: import Laly

Using Swift Package Manager

  1. Xcode -> File -> Swift Packages -> Add Package Dependecy...

  2. Add package dependecy URL: https://github.com/Andrei-Popilian/Laly.git

  3. Use version 1.3.0 +

  4. Import the Laly framework/module.

  • Swift: import Laly

That's it - now go write some beautiful Auto Layout code!


   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)


   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)


    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)))


    someView.widthAnchor.constraint(equalTo: self.view.widthAnchor),
    someView.heightAnchor.constraint(equalTo: self.view.heightAnchor),  


   someView.laly.size(of: self.view)


   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()

Problems, Suggestions, Pull Requests?

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.


Stars: 2


Used By

Total: 0