{"id":1268,"url":"https://github.com/ruipfcosta/AutoLayoutPlus","last_synced_at":"2025-07-30T20:32:59.640Z","repository":{"id":49362007,"uuid":"47155665","full_name":"ruipfcosta/AutoLayoutPlus","owner":"ruipfcosta","description":"A bit of steroids for AutoLayout, powered by Swift.","archived":false,"fork":false,"pushed_at":"2017-04-14T21:29:57.000Z","size":27,"stargazers_count":27,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-29T19:22:38.582Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ruipfcosta.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":"2015-12-01T00:53:19.000Z","updated_at":"2022-07-25T01:32:18.000Z","dependencies_parsed_at":"2022-09-04T14:02:36.143Z","dependency_job_id":null,"html_url":"https://github.com/ruipfcosta/AutoLayoutPlus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruipfcosta%2FAutoLayoutPlus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruipfcosta%2FAutoLayoutPlus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruipfcosta%2FAutoLayoutPlus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruipfcosta%2FAutoLayoutPlus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruipfcosta","download_url":"https://codeload.github.com/ruipfcosta/AutoLayoutPlus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187614,"owners_count":17882335,"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":"2024-01-05T20:15:42.585Z","updated_at":"2024-12-04T20:31:12.025Z","avatar_url":"https://github.com/ruipfcosta.png","language":"Swift","funding_links":[],"categories":["Layout"],"sub_categories":["Other Hardware","Other free courses"],"readme":"# AutoLayoutPlus\n\n[![Platform](http://img.shields.io/badge/platform-ios-blue.svg?style=flat\n)](https://developer.apple.com/iphone/index.action)\n[![Language](http://img.shields.io/badge/language-swift-brightgreen.svg?style=flat\n)](https://developer.apple.com/swift)\n[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\n)](http://mit-license.org)\n[![CocoaPods](https://img.shields.io/cocoapods/v/AutoLayoutPlus.svg)]()\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nAutoLayoutPlus is a Swift library consisting in a set of extensions to help dealing with Auto Layout programatically. \nWith AutoLayoutPlus you don't need to change the way you've always worked with Auto Layout, it should feel as natural complement.\n\nKeep reading for some more details on what's included (and have a look at the example provided)!\n\n## Features\n\n- [x] AutoLayoutPlus complements the existing UIKit methods to create constraints for your views.\n- [x] Helper methods for the most repetitive tasks (center view, apply the same constraint to multiple views, fill view horizontally, etc).\n- [x] Makes your code less verbose and easier to follow.\n- [x] No need to learn yet another DSL or library: AutoLayoutPlus feels natural and provides a similar experience to the methods you are already familiar with!\n\n## Extensions\n\nAutoLayoutPlus works by adding some useful extensions to NSLayoutConstraint and UIView classes. To make use of those extensions don't forget to import AutoLayoutPlus into your code:\n\n```swift\nimport AutoLayoutPlus\n```\n\nTo help reducing the verbosity of the code, the ```multiplier``` and ```constant``` arguments have default values 1 and 0, respectively, so you won't have to specify them unless absolutely necessary.\n\n### NSLayoutConstraint extensions\n\n```swift\nconvenience init(item view1: AnyObject, attribute attr1: NSLayoutAttribute, relatedBy relation: NSLayoutRelation, toItem view2: AnyObject?, attribute attr2: NSLayoutAttribute)\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\n\n// AutoLayoutPlus style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY)\n```\n\n---\n\n```swift\nclass func withFormat(format: String, options: NSLayoutFormatOptions = NSLayoutFormatOptions(rawValue: 0), metrics: [String : AnyObject]? = nil, views: [String : AnyObject]) -\u003e [NSLayoutConstraint]\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint.constraintsWithVisualFormat(\"V:|[topContainer(==60)]\", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)\n\n// AutoLayoutPlus style\nNSLayoutConstraint.withFormat(\"V:|[topContainer(==60)]\", views: views)\n```\n\n---\n\n```swift\nclass func constraints(items views: [AnyObject], attribute attr1: NSLayoutAttribute, relatedBy relation: NSLayoutRelation, toItem view: AnyObject?, attribute attr2: NSLayoutAttribute, multiplier: CGFloat = 1, constant c: CGFloat = 0) -\u003e [NSLayoutConstraint]\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerGreenContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerOrangeContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\n\n// AutoLayoutPlus style\nNSLayoutConstraint.constraints(items: [centerBlueContainer, centerGreenContainer, centerOrangeContainer], attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY)\n```\n\n### UIView extensions\n\n```swift\nfunc centeredInParent(multiplierX: CGFloat = 1, constantX: CGFloat = 0, multiplierY: CGFloat = 1, constantY: CGFloat = 0) -\u003e [NSLayoutConstraint]\nfunc centeredInView(view: UIView, multiplierX: CGFloat = 1, constantX: CGFloat = 0, multiplierY: CGFloat = 1, constantY: CGFloat = 0) -\u003e [NSLayoutConstraint]\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0)\n        \n// AutoLayoutPlus style\ncenterBlueContainer. centeredInParent()\n```\n\n---\n\n```swift\nfunc centeredInParentY(multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc centeredInParentX(multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc centeredInViewY(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc centeredInViewX(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\n        \n// AutoLayoutPlus style\ncenterBlueContainer. centeredInParentY()\n```\n\n---\n\n```swift\nfunc sameDimensionsAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e [NSLayoutConstraint]\nfunc sameDimensionsAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e [NSLayoutConstraint]\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerBlueContainer, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)\n        \n// AutoLayoutPlus style\ncenterBlueContainer. sameDimensionsAsParent()\n```\n\n---\n\n```swift\nfunc sameHeightAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc sameWidthAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc sameHeightAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\nfunc sameWidthAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -\u003e NSLayoutConstraint\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)\n        \n// AutoLayoutPlus style\ncenterBlueContainer. sameHeightAsParent()\n```\n\n---\n\n```swift\nfunc likeParent() -\u003e [NSLayoutConstraint]\nfunc likeView(view: UIView) -\u003e [NSLayoutConstraint]\n```\n\n#### Usage:\n\n```swift\n// Old style\nNSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerBlueContainer, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)\nNSLayoutConstraint(item: centerBlueContainer, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0)\n     \n// AutoLayoutPlus style\ncenterBlueContainer. likeParent()\n```\n\n## Requirements\n\n* iOS 8.0+\n* Xcode 7.0+\n\n## Instalation\n\n### CocoaPods\n\n[CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate AutoLayoutPlus into your Xcode project using CocoaPods, include this in your Podfile:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'AutoLayoutPlus'\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate AutoLayoutPlus into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"ruipfcosta/AutoLayoutPlus\" \"master\"\n```\n\nRun `carthage` to build the framework and drag the built `AutoLayoutPlus.framework` into your Xcode project.\n\n## Credits\n\nOwned and maintained by Rui Costa ([@ruipfcosta](https://twitter.com/ruipfcosta)). \n\n## Contributing\n\nBug reports and pull requests are welcome.\n\n## License\n\nAutoLayoutPlus is released under the MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruipfcosta%2FAutoLayoutPlus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruipfcosta%2FAutoLayoutPlus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruipfcosta%2FAutoLayoutPlus/lists"}