Skip to content

Shorter way to add subviews

Latest

Choose a tag to compare

@dimayurkovski dimayurkovski released this 05 Nov 13:27
· 3 commits to main since this release

New

  • .orbital.add() adds a subview and activates its constraints in one call:
    • view.orbital.add(label, [.top(16), .leading(16), .trailing(16)])
    • label.orbital.add(to: view, [.top(16), .leading(16), .trailing(16)])
    • label.orbital.add(to: controller, [.top(16), .leading(16)])
    • view.orbital.add(avatar, nameLabel) { ... } for several subviews
  • All of them accept an array or a variadic list. Except for the closure form, they return the activated constraints: let constraints = view.orbital.add(label, .top(16))

Unchanged

  • orbit(add:) and orbit(to:) keep working with no changes on your side. They now forward to add()

Docs

  • README now shows .orbital.add() as the primary form