{"id":1284,"url":"https://github.com/mergesort/Anchorman","last_synced_at":"2025-08-02T04:30:55.939Z","repository":{"id":56901960,"uuid":"59773732","full_name":"mergesort/Anchorman","owner":"mergesort","description":"An autolayout library for the damn fine citizens of San Diego.","archived":false,"fork":false,"pushed_at":"2021-01-17T15:13:42.000Z","size":5132,"stargazers_count":81,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-30T05:04:10.574Z","etag":null,"topics":["autolayout","ios"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mergesort.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-26T18:30:33.000Z","updated_at":"2024-12-20T16:32:01.000Z","dependencies_parsed_at":"2022-08-20T18:50:42.110Z","dependency_job_id":null,"html_url":"https://github.com/mergesort/Anchorman","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/mergesort/Anchorman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FAnchorman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FAnchorman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FAnchorman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FAnchorman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mergesort","download_url":"https://codeload.github.com/mergesort/Anchorman/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FAnchorman/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267318852,"owners_count":24068489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autolayout","ios"],"created_at":"2024-01-05T20:15:42.931Z","updated_at":"2025-08-02T04:30:55.886Z","avatar_url":"https://github.com/mergesort.png","language":"Swift","funding_links":[],"categories":["Layout","Swift","\u003ca name=\"for-projects\"\u003e\u003c/a\u003e For Projects"],"sub_categories":["Other Hardware","Other free courses","\u003ca name=\"for-projects-example-projects\"\u003e\u003c/a\u003e Example Projects"],"readme":"# Anchorman\n\n[![BuddyBuild](https://dashboard.buddybuild.com/api/statusImage?appID=59a836506532420001f89b3b\u0026branch=master\u0026build=latest)](https://dashboard.buddybuild.com/apps/59a836506532420001f89b3b/build/latest?branch=master) \n[![Pod Version](https://img.shields.io/badge/Pod-3.1-6193DF.svg)](https://cocoapods.org/)\n![Swift Version](https://img.shields.io/badge/Swift-4.2-brightgreen.svg)\n![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg) \n![Plaform](https://img.shields.io/badge/Platform-iOS-lightgrey.svg)\n\n### Do you think autolayout has to be hard?\n\n![That doesn't make any sense](gifs/doesnt_make_sense.gif)\n\nNah. `NSLayoutAnchor` is pretty neat! But it's still a bit tedious of an API. Try writing `.translatesAutoresizingMaskIntoConstraints = false` and `.isActive = true` 10 times over. But we can make it a bit easier with a *very* thin layer of abstraction.\n\n![I don't know what we're yelling about!](gifs/yelling.gif)\n\n### Let's start off with a vocabulary lesson.\n---\n\n`UIView` and `UILayoutGuide` are `Anchorable`. You can pin one to the other, in any combination you like, as long as it generates valid `NSLayoutConstraint`s.\n\n### How's it work?\n---\n\nI am a cool developer, making a cool app. It has so many views. I want to pin my view to it's superview.\n\n```swift\nself.backgroundView.pinToSuperview()\n```\n\nThat was easy, but I don't want to pin to a superview anymore, I want to pin to another view.\n\n```swift\nself.messageLabel.pin(to: self.backgroundView)\n```\n\nAh, ok. Easy enough… How about pinning my label to the left and right side of it's superview… and with insets… and center it in my view.\n\n```swift\nself.titleLabel.pinToSuperview([ .leading(10.0), .trailing(10.0), .centerY ])\n```\n\nWhoa, that was neat! You can specify a group of edges you want to pin to, and their offsets. Swift enums are the best!\n\n![That escalated quickly](gifs/escalated_quickly.gif)\n\nAnd of course, you can pick one edge to pin to another edge.\n\n```swift\nself.footerLabel.pin(edge: .bottom, toEdge: .bottom, of: self.view.safeAreaLayoutGuide, constant: 10.0)\n```\n\nLast but not least, set constant values for your \nconstraints. For width, height, or both.\n\n```swift\nself.footerLabel.set(size: .width(44.0) ])\nself.titleLabel.set(size: [ .width(44.0), .height(44.0) ])\n```\n\nI lied, there's a bit more. Anchorman includes a couple of goodies to make your life easier between iOS 10 and iOS 11.\n\n```swift\nvar backwardsCompatibleSafeAreaLayoutGuide: UILayoutGuide \nvar backwardsCompatibleSafeAreaInsets: UIEdgeInsets \n```\n\nThese will use `safeAreaLayoutGuide` and `safeAreaInsets` on iOS 11, and `layoutMarginsGuide` and `layoutMargins` on iOS 10, so you can avoid a whole bunch of `if #available` conditions.\n\n## Installation\nAnchorman supports Swift 4 with the latest versions. If you're looking for Swift 3 support, use [version 2.0](https://github.com/mergesort/Anchorman/releases/tag/2.0)\n\nYou can use CocoaPods to install Anchorman by adding it to your Podfile:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'Anchorman'\n```\n\nOr Carthage\n\n```swift\ngithub \"mergesort/Anchorman\"\n```\n\nOr install it the old fashioned way by downloading `Anchorman.swift` and dropping it in your project.\n\n## About me\n\n![I'm Ron Burgundy](gifs/im_ron_burgundy.gif)\n\nHi, I'm Joe! [@mergesort](http://fabisevi.ch) everywhere on the web, but especially on [Twitter](https://twitter.com/mergesort).\n\n## License\n\nSee the [license](LICENSE) for more information about how you can use Anchorman. I promise it's not GPL, because I am not \"that guy\".\n\n## Fin\n\nHopefully Anchorman is your cup of tea, it's the kind of autolayout library I'd want to use. And with that, good night San Diego.\n\n![Stay Classy San Diego](gifs/stay_classy.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FAnchorman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmergesort%2FAnchorman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FAnchorman/lists"}