{"id":31144337,"url":"https://github.com/chris-perkins/clingconstraints","last_synced_at":"2025-09-18T14:39:44.133Z","repository":{"id":56906008,"uuid":"138513317","full_name":"Chris-Perkins/ClingConstraints","owner":"Chris-Perkins","description":"Yet another library for programmatic constraints in iOS; emphasis on readability.","archived":false,"fork":false,"pushed_at":"2019-06-08T18:55:03.000Z","size":1281,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T18:09:38.235Z","etag":null,"topics":["constraints","ios","nslayoutconstraint","nslayoutconstraints","programmatic","swift","uilayout"],"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/Chris-Perkins.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":"2018-06-24T20:31:18.000Z","updated_at":"2019-09-07T19:08:07.000Z","dependencies_parsed_at":"2022-08-20T19:20:15.421Z","dependency_job_id":null,"html_url":"https://github.com/Chris-Perkins/ClingConstraints","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Chris-Perkins/ClingConstraints","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FClingConstraints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FClingConstraints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FClingConstraints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FClingConstraints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chris-Perkins","download_url":"https://codeload.github.com/Chris-Perkins/ClingConstraints/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FClingConstraints/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275782384,"owners_count":25527597,"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-09-18T02:00:09.552Z","response_time":77,"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":["constraints","ios","nslayoutconstraint","nslayoutconstraints","programmatic","swift","uilayout"],"created_at":"2025-09-18T14:39:42.953Z","updated_at":"2025-09-18T14:39:44.124Z","avatar_url":"https://github.com/Chris-Perkins.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"Readme_Imgs/ClingConstraintsHeader.png\" /\u003e\n\u003c/p\u003e\n\n\n[![Version](https://img.shields.io/cocoapods/v/ClingConstraints.svg?style=flat)](https://cocoapods.org/pods/ClingConstraints)\n[![License](https://img.shields.io/cocoapods/l/ClingConstraints.svg?style=flat)](https://cocoapods.org/pods/ClingConstraints)\n[![Platform](https://img.shields.io/cocoapods/p/ClingConstraints.svg?style=flat)](https://cocoapods.org/pods/ClingConstraints)\n\nYet another programmatic constraints library for iOS. The focus of ClingConstraints is to have clean, readable, and powerful constraint creation.\n\nFor instance, `thisView.copy(.height, of: thatView)`\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Readme_Imgs/ClingConstraintsDemo.gif\" /\u003e \u003cimg src=\"Readme_Imgs/MovingBox.gif\" /\u003e \u003cimg src=\"Readme_Imgs/StackingBoxes.gif\" /\u003e\n\u003c/p\u003e\n\n## Features\n\n✅ One-line constraint creation  \n✅ One-line copy of multiple constraints  \n✅ Chainable property editing for constraints  \n✅ Clinging differing constraint attributes together  \n✅ One-line vertical or horizontal view filling  \n✅ Auto-disable `translatesAutoresizingMaskIntoConstraints`  \n✅ Automatically activate constraints  \n✅ NSLayoutConstraint collection mass activation/deactivation  \n❌ Something bad \n\n\n## Installation\n\n1. Install [CocoaPods](https://cocoapods.org)\n1. Add this repo to your `Podfile`\n\n\t```ruby\n\ttarget 'Example' do\n\t\t# IMPORTANT: Make sure use_frameworks! is included at the top of the file\n\t\tuse_frameworks!\n\n\t\tpod 'ClingConstraints'\n\tend\n\t```\n1. Run `pod install` in the podfile directory from your terminal\n1. Open up the `.xcworkspace` that CocoaPods created\n1. Done!\n\n## Examples\n\n##### Copy another View's Attribute\n```Swift\n//  Creates and activates a constraint that makes thisView's height equal to thatView's\nthisView.copy(.height, of: thatView)\n```\n\n##### Copying Constraints with Personal Space\n```Swift\n// thisView copies thatView's height * 0.5 - 30.\nthisView.copy(.height, of: thatView).withOffset(-30).withMultiplier(0.5)\n```\n\n##### Copying Multiple Constraints In-Line\n```Swift\n// thisView copies the right, top, and left anchor constraints of that view-- in one line.\nthisView.copy(.right, .top, .left, of: thatView)\n```\n\n##### Clinging Constraints Together\n```Swift\n// thisView positions itself to the right of thatView with a spacing of 5\nthisView.cling(.left, to: thatView, .right).withOffset(5)\n```\n\n##### Filling a View\n```Swift\n// Fills a view from the top to the bottom with the given views\nthisView.fill(.topToBottom, withViews: [thatView1, thatView2], spacing: 0)\n```\n\n#### What's in the box?\n\n##### Constraint Creation:\nOn any UIView, you can call the following functions.\n\nNote that these all return the created constraint. If multiple constraints are created, a list of constraints are returned.\n```Swift\n// This view copies the other view's attributes (returns list of created constraints)\ncopy(_: NSLayoutAttribute..., of: UIView)\n\n// This view copies the other view's attribute\ncopy(_: NSLayoutAttribute, of: UIView)\n\n// Clings the calling view's attribute to the other view's attribute.\ncling(_: NSLayoutAttribute, to: UIView, _: NSLayoutAttribute)\n\n// Fills the calling view with the given FillMethod from left to right.\n// FillMethods: .leftToRight, .rightToLeft, .topToBottom, .bottomToTop\nfill(_: FillMethod, withViews: [UIView], withSpacing: CGFloat, spacesInternally: Bool = true)\n\n// Sets the height for this view\nsetHeight(_: CGFloat)\n\n// Sets the width for this view\nsetWidth(_: CGFloat)\n```\n\n\n##### Constraint Property Chaining:\nOn any NSLayoutConstraint:\n```Swift\nwithMultiplier(_: CGFloat)\nwithOffset(_: CGFloat)\nwithPriority(_: UILayoutPriority)\nwithRelation(_: NSLayoutRelation)\n```\n\n#### For constraint activation and deactivation:\nIn any collection of constraints:\n```Swift\nactivateAllConstraints()\ndeactivateAllConstraints()  \n```\n\n## Example Project\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"Readme_Imgs/ClingConstraintsDemo.gif\" /\u003e\n\u003c/p\u003e\n\nThe example project in this repository will show how the above animation was created using constraints. Clone this repository and open `.xcodeproj` file located in the \"Example Project\" directory. \n\n## Documentation\n\nRead the [docs](https://htmlpreview.github.io/?https://raw.githubusercontent.com/Chris-Perkins/ClingConstraints/master/docs/index.html)\n\n## Author\n\n[Chris Perkins](chrisperkins.me)\n\nThanks to [Luis Padron](https://github.com/luispadron) for helping set this up! 👍\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-perkins%2Fclingconstraints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris-perkins%2Fclingconstraints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-perkins%2Fclingconstraints/lists"}