{"id":1276,"url":"https://github.com/indragiek/SwiftAutoLayout","last_synced_at":"2025-07-30T20:32:59.117Z","repository":{"id":17960577,"uuid":"20949679","full_name":"indragiek/SwiftAutoLayout","owner":"indragiek","description":"Tiny Swift DSL for Autolayout","archived":false,"fork":false,"pushed_at":"2021-09-11T01:31:23.000Z","size":73,"stargazers_count":655,"open_issues_count":9,"forks_count":44,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-10-13T17:48:19.468Z","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/indragiek.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":"2014-06-18T04:44:04.000Z","updated_at":"2024-08-02T03:09:57.000Z","dependencies_parsed_at":"2022-09-24T20:13:15.021Z","dependency_job_id":null,"html_url":"https://github.com/indragiek/SwiftAutoLayout","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/indragiek%2FSwiftAutoLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indragiek%2FSwiftAutoLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indragiek%2FSwiftAutoLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indragiek%2FSwiftAutoLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indragiek","download_url":"https://codeload.github.com/indragiek/SwiftAutoLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187620,"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.746Z","updated_at":"2024-12-04T20:31:12.192Z","avatar_url":"https://github.com/indragiek.png","language":"Swift","readme":"## SwiftAutoLayout\n\nSwiftAutoLayout is a tiny DSL for Autolayout intended to provide a more declarative way to express layout constraints. Here's a quick example:\n\n```swift\n// this:\nlet constraint = view1.left == view2.right * 2.0 + 10.0 ~ 750\n\t\t\n// is equivalent to:\nlet constraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Right, multiplier: 2.0, constant: 10.0)\nconstraint.priority = 750\n```\n\nYou may notice that this looks a lot like the linear equation that a constraint represents. From the [Apple documentation](https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSLayoutConstraint_Class/NSLayoutConstraint/NSLayoutConstraint.html):\n\n\u003e The relationship involves a first attribute, a relationship type, and a modified second value formed by multiplying an attribute by a constant factor and then adding another constant factor to it. In other words, constraints look very much like linear equations of the following form:\n\u003e\n\u003e `attribute1 == multiplier × attribute2 + constant`\n\nSwiftAutoLayout allows you to more effectively communicate the intent of a constraint by making the syntax more similar to the equation that it represents.\n\n### Installing\n\nUse [Swift Package Manager](https://github.com/apple/swift-package-manager) or add `SwiftAutoLayout.xcodeproj` as a subproject and link against either `SwiftAutoLayout-iOS.framework` or `SwiftAutoLayout-Mac.framework` depending on the platform.\n\n### Attributes\n\nLayout attributes are defined as properties added in extensions of `UIView` and `UILayoutGuide` on iOS and `NSView` and `NSLayoutGuide` on OS X. For example, `UIView.width` and `UIView.height` represent `NSLayoutAttribute.Width` and `NSLayoutAttribute.Height`, respectively.\n\nLayout guides (conforming to `UILayoutSupport`) in `UIViewController` are also supported using the `topLayoutGuideTop`, `topLayoutGuideBottom`, `bottomLayoutGuideTop`, and `bottomLayoutGuideBottom` properties.\n\n### Relations\n\nRelations are expressed using the overloaded operators `==` (`NSLayoutRelation.Equal`), `\u003e=` (`NSLayoutRelation.GreaterThanOrEqual`), and `\u003c=` (`NSLayoutRelation.LessThanOrEqual`). \n\n### Examples\n\n#### Activating Single Constraint\n\n```swift\n(view1.left == view2.right * 2.0 + 10.0 ~ 750).active = true\n```\n\n#### Activating Multiple Constraints\n\n```swift\nNSLayoutConstraint.activateConstraints([\n    view2.centerX == view2.superview!.centerX,\n    view2.centerY == view2.superview!.centerY,\n    view1.left == view2.right * 2.0 + 10.0 ~ 750,\n    view1.top == view2.bottom + 5.0,\n    view1.width \u003e= 200,\n    view1.height \u003e= 400,\n    view1.trailing == layoutGuide.trailing,\n    view2.leading == layoutGuide.leading\n])\n```\n\n### Contact\n\n* Indragie Karunaratne\n* [@indragie](http://twitter.com/indragie)\n* [http://indragie.com](http://indragie.com)\n\n### License\n\nSwiftAutoLayout is licensed under the MIT License.\n","funding_links":[],"categories":["Layout","Libs"],"sub_categories":["Other Hardware","Other free courses","Layout","Auto Layout"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findragiek%2FSwiftAutoLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findragiek%2FSwiftAutoLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findragiek%2FSwiftAutoLayout/lists"}