[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6766":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":22,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},6766,"Cartography","robb\u002FCartography","robb","A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:","",null,"Swift",7327,527,179,58,0,3,39.17,"Other",false,"master",true,[],"2026-06-12 02:01:29","# Cartography :iphone::triangular_ruler:\n\n\u003Ca href=\"https:\u002F\u002Ftravis-ci.org\u002Frobb\u002FCartography?branch=master\">\n    \u003Cimg src=\"https:\u002F\u002Ftravis-ci.org\u002Frobb\u002FCartography.svg?branch=master\" hspace=\"6px\" align=\"right\" vspace=\"2px\">\n\u003C\u002Fa>\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage\u002Fissues\u002F179\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCarthage-compatible-4BC51D.svg?style=flat\" align=\"right\" vspace=\"2px\">\n\u003C\u002Fa>\n\nUsing Cartography, you can set up your Auto Layout constraints in declarative code and without any stringly typing!\n\nIn short, it allows you to replace this:\n\n\u003Cimg src=\"\u002Fimages\u002Fpirates2.png\" align=\"right\" height=\"280px\" hspace=\"30px\" vspace=\"30px\">\n\n```Swift\naddConstraint(NSLayoutConstraint(\n    item: button1,\n    attribute: .Right,\n    relatedBy: .Equal,\n    toItem: button2,\n    attribute: .Left,\n    multiplier: 1.0,\n    constant: -12.0\n))\n```\n\nwith this\n\n```Swift\nconstrain(button1, button2) { button1, button2 in\n    button1.right == button2.left - 12\n}\n```\n\nIf you end up using Cartography in production, I'd love to hear from you. You can reach me through [Twitter] or [email].\n\n## Installation\n\n### CocoaPods\n\nTo integrate Cartography into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\ntarget '\u003CYour Target Name>' do\n  pod 'Cartography', '~> 3.0'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n## Usage\n\nCall the `constrain`_*_ function with your `UIView` or `NSView` instances as well\nas a closure in which you declare the constraints between the different\nattributes of your views:\n\n```swift\nconstrain(view1, view2) { view1, view2 in\n    view1.width   == (view1.superview!.width - 50) * 0.5\n    view2.width   == view1.width - 50\n    view1.height  == 40\n    view2.height  == view1.height\n    view1.centerX == view1.superview!.centerX\n    view2.centerX == view1.centerX\n\n    view1.top >= view1.superview!.top + 20\n    view2.top == view1.bottom + 20\n}\n```\n\n\u003Cimg src=\"\u002Fimages\u002Fpirates1.png\" align=\"left\" height=\"220px\" hspace=\"20px\" vspace=\"10px\">\n\nFor every view on the left hand side of an equality or inequality operator,\nCartography will automatically set its\n`translatesAutoresizingMaskIntoConstraints` property to `false`.\n\nIf the view is\nnot controlled by you–for example _if it belongs to a Apple-provided\n`UIViewController` class_–you should take appropriate care when declaring its\nconstraints.\n\n\u003Cbr>\u003Cbr>\n\n## Replacing constraints\n\nYou can capture multiple constraints in a group to then replace them with new\nconstraints at a later point.\n\n```swift\nconstrain(view) { view in\n    view.width  == 100\n    view.height == 100\n}\n\nlet group = ConstraintGroup()\n\n\u002F\u002F Attach `view` to the top left corner of its superview\nconstrain(view, replace: group) { view in\n    view.top  == view.superview!.top\n    view.left == view.superview!.left\n}\n\n\u002F* Later *\u002F\n\n\u002F\u002F Move the view to the bottom right corner of its superview\nconstrain(view, replace: group) { view in\n    view.bottom == view.superview!.bottom\n    view.right  == view.superview!.right\n}\n\nUIView.animate(withDuration: 0.5, animations: view.layoutIfNeeded)\n```\n\nFor convenience, the `constrain` functions also returns `ConstraintGroup`\ninstances:\n\n```swift\nlet group = constrain(button) { button in\n    button.width  == 100\n    button.height == 400\n}\n```\n\n## Supported attributes\n\n\nCartography supports all built-in attributes as of iOS 8 and OS X 10.9, those are:\n\n\u003Cimg src=\"\u002Fimages\u002Fpirates3.png\" align=\"right\" height=\"400px\" hspace=\"20px\" vspace=\"100px\">\n\n- `width`\n- `height`\n- `top`\n- `right`\n- `bottom`\n- `left`\n- `leading`\n- `trailing`\n- `centerX`\n- `centerY`\n- `baseline`\n\nas well as the iOS specific\n\n- `firstBaseline`\n- `leftMargin`\n- `rightMargin`\n- `topMargin`\n- `bottomMargin`\n- `leadingMargin`\n- `trailingMargin`\n- `centerXWithinMargins`\n- `centerYWithinMargins`\n- `edgesWithinMargins`\n\nThese can be further refined using the following operators: `*`, `\u002F`, `+` and\n`-`.\n\nAdditionally, it supports convenient compound attributes that allow you to\nassign multiple attributes at once:\n\n```swift\nconstrain(view) { view in\n    view.size   == view.superview!.size \u002F 2\n    view.center == view.superview!.center\n}\n```\n\n```swift\nconstrain(view) { view in\n    view.edges == inset(view.superview!.edges, 20, 20, 40, 20)\n}\n```\n\n### Aligning multiple view\n\nIf you need to align multiple views by a common edge, you can use the `align`\nfunctions:\n\n```swift\nconstrain(view1, view2, view3) { view1, view2, view3 in\n    align(top: view1, view2, view3)\n}\n```\n\nWhich is equivalent to `view1.top == view2.top; view2.top == view3.top`. Similar\nvariants exist for `top`, `right` `bottom`, `left`, `leading`, `trailing`,\n`centerX`, `centerY` and `baseline`.\n\n### Distributing views evenly\n\nFor distributing multiple views, either horizontally or vertically, you can use\nthe `distribute` functions:\n\n```swift\nconstrain(view1, view2, view3) { view1, view2, view3 in\n    distribute(by: 10, horizontally: view1, view2, view3)\n}\n```\n\nWhich is equivalent to `view1.trailing == view2.leading - 10; view2.trailing == view3.leading - 10`.\n\n## Setting priorities\n\nYou can set the priorities of your constraints using the `~` operator:\n\n```swift\nconstrain(view) { view in\n    view.width  >= 200 ~ UILayoutPriority(100)\n    view.height >= 200 ~ .required\n}\n```\n\n## Capturing constraints\n\nSince the `==`, `>=`, `\u003C=` and `~` emit `NSLayoutConstraint` instances, you can\ncapture their results if you need to refer to the layout constraints at a later\ntime:\n\n```swift\nvar width: NSLayoutConstraint?\n\nconstrain(view) { view in\n    width = (view.width == 200 ~ 100)\n}\n```\n\nNote that declaring compound attributes returns multiple constraints at once:\n\n```swift\nvar constraints: [NSLayoutConstraint]?\n\nconstrain(view) { view in\n    constraints = (view.size == view.superview!.size ~ .defaultLow)\n}\n```\n\n## Documentation\n\nRead the documentation [here](http:\u002F\u002Frobb.github.io\u002FCartography\u002F). For more information, see the [gh-pages](https:\u002F\u002Fgithub.com\u002Frobb\u002FCartography\u002Ftree\u002Fgh-pages) branch.\n\n\n\\* Since Xcode 11 and swift 5.1 the keyword `constrain` conflicts with the ones used by the **CommonUISDK**... so, Calling the function with the module name is necessary to make it work properly\n\ne.g.: `Cartography.constrain`\n\nIf you're using it with Xcode 10.3 or earlier, you can still use it as it is, without the module name alongside the function.\n\n## Versioning\n\nFor *Swift 3.x*: Versions \u003C= 1.1.0\n\nFor *Swift 4.x*: Versions >= 2.0.0\n\nFor *Swift 5.x*: Versions >= 4.0.0\n\n## Support\n\nPlease, don't hesitate to [file an\nissue](https:\u002F\u002Fgithub.com\u002Frobb\u002FCartography\u002Fissues\u002Fnew) if you have questions.\n\n## About Cartography\n\nCartography was built by [Robb Böhnke][me], is maintained by [Orta Therox][ot] and was inspired by the excellent\n[FLKAutoLayout] by [Florian Kugler][florian].\n\n[flkautolayout]: https:\u002F\u002Fgithub.com\u002Ffloriankugler\u002FFLKAutoLayout\n[florian]:       https:\u002F\u002Fgithub.com\u002Ffloriankugler\n[me]:            http:\u002F\u002Frobb.is\n[twitter]:       https:\u002F\u002Ftwitter.com\u002Fdlx\n[email]:         mailto:robb@robb.is\n[ot]:            https:\u002F\u002Fgithub.com\u002Forta\n","Cartography 是一个用于 Swift 的声明式 Auto Layout DSL。它允许开发者通过简洁的语法来定义界面布局约束，避免了传统的字符串键值对方式可能带来的错误，并且提高了代码的可读性和维护性。项目支持使用闭包来表达复杂的布局关系，使得视图之间的约束设置更加直观。适用于需要构建复杂用户界面的iOS或macOS应用开发场景中，特别是当项目追求更高的代码质量和开发效率时。",2,"2026-06-11 03:08:45","top_language"]