Cartography icon indicating copy to clipboard operation
Cartography copied to clipboard

Acknowledge Apple's current AutoLayout syntax in Readme (since iOS 9.0)

Open sovata8 opened this issue 7 years ago • 1 comments

I think it would be a good idea to acknowledge the fact that, while Apple's original AutoLayout API syntax is indeed very verbose, since iOS9 it can be rewritten using their anchor syntax.

For example this code from the Readme file:

addConstraint(NSLayoutConstraint(
    item: button1,
    attribute: .Right,
    relatedBy: .Equal,
    toItem: button2,
    attribute: .Left,
    multiplier: 1.0,
    constant: -12.0
))

becomes:

button1.rightAnchor.constraint(equalTo: button2.leftAnchor, constant: -12.0)

And indeed this points to the fact that in some cases, Apple's anchor syntax is pretty good (in this specific case, it's shorter than Cartography's).

Of course in many other cases Cartography's syntax is probably still shorter even than Apple's revised syntax. Moreover, if a user targets lower than iOS9, then Cartography offers a solution there.

But I think users should be made aware of this revised Apple syntax, so they can make an informed decision about the best solution for their project.

sovata8 avatar May 11 '17 14:05 sovata8

Sure, PRs are welcome.

orta avatar May 11 '17 20:05 orta