Position a button 12 points to the right of another button in your iOS app with one line instead of the eight-line native Auto Layout call
Animate a layout change by swapping a named constraint group for a new one and triggering a UIView animation block
Distribute a row of buttons at equal spacing across the screen with a single Cartography function call
Install via CocoaPods, use version 4.x or above for Swift 5 compatibility.
Cartography is a Swift library for iOS and macOS developers that makes positioning user interface elements on screen much less verbose. On Apple platforms, views (buttons, images, text labels, and so on) are sized and placed using a system called Auto Layout, where you define rules describing how elements should relate to each other in size and position. The native Auto Layout API requires a long, repetitive call for each rule. Cartography replaces this with a shorter, more readable style where constraints are written as familiar math-like expressions inside a small function call. For example, saying that one button's right edge should sit 12 points to the left of another button's left edge takes about 8 lines with the native API. With Cartography the same rule fits on one line. The library supports all standard layout attributes built into iOS and macOS: width, height, top, bottom, left, right, center, baseline, and the various margin and alignment variants. Compound shortcuts let you set multiple attributes at once, such as matching an element's full size to another view or placing it at its parent's center. Aligning a group of views along a shared edge, or distributing several views at even spacing, each require a single call. Constraints can be captured into named groups and then replaced later with new constraints, which makes animated layout transitions straightforward. A shorthand operator lets you attach a priority value to any rule, which the system uses to decide which constraint to honor when two rules conflict. Installation is via CocoaPods. Version compatibility follows Swift releases: versions 1.x target Swift 3, versions 2.x target Swift 4, and versions 4.x and above target Swift 5.
← robb on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.