{"id":26719880,"url":"https://github.com/truffls/compatible-layout-anchors-ios","last_synced_at":"2025-03-27T18:29:38.945Z","repository":{"id":56906417,"uuid":"113190125","full_name":"truffls/compatible-layout-anchors-ios","owner":"truffls","description":"Automatically apply top/bottom layout anchors without having to check safe area compatibility","archived":false,"fork":false,"pushed_at":"2018-04-24T13:29:21.000Z","size":2231,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T16:07:41.577Z","etag":null,"topics":[],"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/truffls.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-12-05T14:08:26.000Z","updated_at":"2018-10-23T21:01:36.000Z","dependencies_parsed_at":"2022-08-21T03:20:47.988Z","dependency_job_id":null,"html_url":"https://github.com/truffls/compatible-layout-anchors-ios","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truffls%2Fcompatible-layout-anchors-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truffls%2Fcompatible-layout-anchors-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truffls%2Fcompatible-layout-anchors-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truffls%2Fcompatible-layout-anchors-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/truffls","download_url":"https://codeload.github.com/truffls/compatible-layout-anchors-ios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245320796,"owners_count":20596245,"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","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":[],"created_at":"2025-03-27T18:29:38.439Z","updated_at":"2025-03-27T18:29:38.924Z","avatar_url":"https://github.com/truffls.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![alt text](https://github.com/truffls/compatible-layout-anchors-ios/raw/master/readme-images/logo.png \"Compatible Layout Anchors\")\n\n![Swift Version](https://img.shields.io/badge/swift-4.1-orange.svg \"Swift 4.1\")\n![Platform Compatibility](https://img.shields.io/badge/platform-ios-lightgrey.svg \"Platform iOS\")\n![Pod version](https://img.shields.io/badge/pod-v2.0.2-blue.svg \"Pod version 2.0.2\")\n\nAn easy way to support iOS 11 safe area anchors and iOS \u003c=10 top/bottom layout guides at the same time. CompatibleLayoutAnchors takes away the boiler plate code to check which layout anchors to use.\n\n\n### Problem\n\nIf you're using iOS 11's safe area and NIBs for your interfaces the fallback constraints for iOS \u003c=10 falls back to the superview's anchors instead of top/bottom layout guides.\n\nIn a usual workflow you would setup your nib and looking OK in Interface Builder.\n\n![alt text](https://github.com/truffls/compatible-layout-anchors-ios/raw/master/readme-images/setup-nib.png \"Setup NIB\")\n\nBut in iOS \u003c=10 it looks broken.\n\n| Actual | Expected |\n| ------ | -------- |\n| ![alt text](https://github.com/truffls/compatible-layout-anchors-ios/raw/master/readme-images/before.gif \"Broken layout constraints\") | ![alt text](https://github.com/truffls/compatible-layout-anchors-ios/raw/master/readme-images/after.jpg \"Fixed layout constraints\") |\n\n\n### Install via Cocoapods\n\nAdd following to your `Podfile`:\n\n```ruby\nuse_frameworks!\npod 'CompatibleLayoutAnchors'\n```\n\n### How to use\n\nYou have your layout in a NIB file ready with all layout constraints. Reference in your view controller the top constraints connected to the safe area top anchor and the bottom constraints connected to the safe area bottom anchor. Use `assignCompatibleConstraint(_:for:)` to reassign the top and bottom constraints with the appropriate constraints.\n\n```swift\nassignCompatibleConstraint(\u0026myTopConstraint, for: .top)\n```\n\n### Example\n\nThis code fits to the screenshots above.\n\n```swift\nclass ViewController: UIViewController {\n\n    @IBOutlet weak var headlineLabelTopConstraint: NSLayoutConstraint!\n    @IBOutlet weak var footnoteLabelBottomConstraint: NSLayoutConstraint!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        assignCompatibleConstraint(\u0026headlineLabelTopConstraint, for: .top)\n        assignCompatibleConstraint(\u0026footnoteLabelBottomConstraint, for: .bottom)\n    }\n}\n```\n\n### Contribution\n\nIssues and pull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruffls%2Fcompatible-layout-anchors-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruffls%2Fcompatible-layout-anchors-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruffls%2Fcompatible-layout-anchors-ios/lists"}