{"id":15038607,"url":"https://github.com/denislitvin/pinner","last_synced_at":"2026-03-17T23:32:20.929Z","repository":{"id":62450749,"uuid":"108676392","full_name":"DenisLitvin/Pinner","owner":"DenisLitvin","description":"📌 Auto-Layout wrapper (DSL) for more concise and swiftier syntax. ","archived":false,"fork":false,"pushed_at":"2019-05-03T16:45:03.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-13T13:14:11.602Z","etag":null,"topics":["anchors","auto","constraints","layout","pinner","swift","ui","uikit","uiview","xcode"],"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/DenisLitvin.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-10-28T19:05:24.000Z","updated_at":"2019-05-03T16:45:05.000Z","dependencies_parsed_at":"2022-11-01T22:32:06.354Z","dependency_job_id":null,"html_url":"https://github.com/DenisLitvin/Pinner","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenisLitvin%2FPinner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenisLitvin%2FPinner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenisLitvin%2FPinner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenisLitvin%2FPinner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DenisLitvin","download_url":"https://codeload.github.com/DenisLitvin/Pinner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243410458,"owners_count":20286403,"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":["anchors","auto","constraints","layout","pinner","swift","ui","uikit","uiview","xcode"],"created_at":"2024-09-24T20:39:11.284Z","updated_at":"2025-12-29T23:18:00.520Z","avatar_url":"https://github.com/DenisLitvin.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pinner\n\n[![CI Status](http://img.shields.io/travis/DenisLitvin/Pinner.svg?style=flat)](https://travis-ci.org/DenisLitvin/Pinner)\n[![Version](https://img.shields.io/cocoapods/v/Pinner.svg?style=flat)](http://cocoapods.org/pods/Pinner)\n[![License](https://img.shields.io/cocoapods/l/Pinner.svg?style=flat)](http://cocoapods.org/pods/Pinner)\n[![Platform](https://img.shields.io/cocoapods/p/Pinner.svg?style=flat)](http://cocoapods.org/pods/Pinner)\n\n## Usage\n\nIf you you want to see the full example, run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n### Pinner\nAll constraints are specified as the input parameters. Call the method of `UIView` - `makeConstraints(for:)` which takes one or more instances of `CSMConstraintType` enumeration, separated with commas.\n```swift\nenum CSMConstraintType {\n    case top\n    case leading\n    case left\n    case bottom\n    case trailing\n    case right\n\n    case height\n    case width\n\n    case centerX\n    case centerY\n}\n```\n\nAll calculations are made in the closure. You can easily pin the view to any side of it's superview with `pin(to:)`, method of the instance of `CSMConstraintPinner`, or `pinAndReturn(to:)` if you want to use the constraint later.\nConstants are made by using `equal(_:)` or `equalAndReturn(_:)` methods.\n\n#### Input parameters for `pin` methods (use in that order):\n- `_ anchor` : NSLayoutAnchor - anchor point.\n-  `const` : CGFloat - constant offset in certain axis.\n- `mult` : CGFLoat - multiplier, uses only for height and width anchors.\n- `options` : CSMConstraintOptions - possible options: `.equal`,  `.lessOrEqual`, `.moreOrEqual`.\n\n**By default you only need to specify the anchor, all constraints are activated and underlying view has it's property `translatesAutoresizingMaskIntoConstraints` set to false!**\n\n#### Input parameter for `equal` methods is only the constant(CGFloat).\n\nYou also have an ability to return all anchors within a closure by using `returnAll()` method on `CSMConstraintPinner`.\nAnd you can deactivate your constraints using `deactivate(_ :)` with the index of constraint, or use `deactivateAll()`.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"sample1.png\" width=\"300\" max-width=\"50%\" /\u003e\n\u003c/p\u003e\n\n### Example\n```swift\nsomeView.makeConstraints(for: .top, .left, .width, .height) { (make) in\n    self.someViewTopAnchor = make.pinAndReturn(to: self.view.topAnchor, const: 30)\n    make.pin(to: self.view.leftAnchor, const: 10)\n    make.pin(to: self.view.widthAnchor, mult: 0.3)\n    make.equal(200)\n}\n```\n### Helper functions\n\n1. Arrange view based on `Safe Area Layout Guide` that works for all devices and ios versions:\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"safeArea.png\" width=\"300\" max-width=\"50%\" /\u003e\n\u003c/p\u003e\n\n```swift\nviewController.fillSafeArea(with: someView)\n```\n\n2. If you want to cover the entire superview:\n```swift\nsomeView.fillSuperview()\n```\n\n3. Anchor to center of a view:\n```swift\nsomeView.anchorCenterSuperview()\n```\nor\n```swift\nsomeView.anchorCenterXToSuperview(constant: 10)\nsomeView.anchorCenterYToSuperview(constant: 5)\n```\n## Installation\n\n**CocoaPods:**\n\nAdd the line `pod \"Pinner\"` to your `Podfile`\n\n**Manual:**\n\nClone the repo and drag the file `Pinner.swift` into your Xcode project.\n\n## Platform support\n\n- iOS 9.3 and above\n\n## Author\n\nDenisLitvin, den.litvinn@gmail.com\n\n## License\n\nPinner is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenislitvin%2Fpinner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenislitvin%2Fpinner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenislitvin%2Fpinner/lists"}