[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6906":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":47,"readmeContent":48,"aiSummary":49,"trendingCount":16,"starSnapshotCount":16,"syncStatus":18,"lastSyncTime":50,"discoverSource":51},6906,"TinyConstraints","roberthein\u002FTinyConstraints","roberthein","Nothing but sugar.","",null,"Swift",4092,195,48,15,0,1,2,4,3,62.28,"MIT License",false,"master",true,[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"animation","arkit","auto","center","constraint","constraints","layout","libraries","library","nslayoutconstraint","nslayoutconstraints","stack","sugar","superview","sweet","swift","swift-5","swift4","swift5","syntactic","2026-06-12 04:00:30","**TinyConstraints** is the syntactic sugar that makes Auto Layout sweeter for human use.\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\"Art\u002Fheader.png\" width=\"890\" alt=\"TinyConstraints\"\u002F>\n\u003C\u002Fp>\n\n## Features\n\n- [X] Pure Swift 5 sweetness.\n- [X] Everything you can do with Auto Layout, but shorter.\n- [X] Constraints are active by default.\n- [X] 100% compatible with other Auto Layout code.\n- [X] Optionally store your constraints.\n- [X] Set constraint priorities upon creation.\n- [X] Constrain directly to the superview.\n- [X] Stack views together with one line of code.\n- [X] No need to set `translatesAutoresizingMaskIntoConstraints` because `TinyConstraints` does it for you.\n\n## Examples\n### Edges\nAttaching a view to its superview with `NSLayoutConstraint`:\n\n```swift\nNSLayoutConstraint.activate([\n    view.topAnchor.constraint(equalTo: superview.topAnchor, constant: 0),\n    view.leadingAnchor.constraint(equalTo: superview.leadingAnchor, constant: 0),\n    view.bottomAnchor.constraint(equalTo: superview.bottomAnchor, constant: 0),\n    view.trailingAnchor.constraint(equalTo: superview.trailingAnchor, constant: 0)\n])\n```\n\nwith `TinyConstraints`:\n\n```swift\nview.edgesToSuperview()\n```\n\nor:\n\n```swift\nview.edgesToSuperview(insets: .top(10) + .left(10))\n```\n### Center\nConstraining the center of a view to its superview with `NSLayoutConstraint`:\n\n```swift\nNSLayoutConstraint.activate([\n    view.centerXAnchor.constraint(equalTo: superview.centerXAnchor, constant: 0)\n    view.centerYAnchor.constraint(equalTo: superview.centerYAnchor, constant: 0)\n])\n```\n\nwith `TinyConstraints`:\n\n```swift\nview.center(in: superview)\n```\n\nor:\n\n```swift\nview.center(in: superview, offset: CGPoint(x: 10, y: 10))\n```\n\n## Basic Use\n\n### Typealiases\n\n`TinyConstraints` gives you convenient and tiny typealiases for handling constraints.\n\n- `Constraint` = `NSLayoutConstraint`\n- `Constraints` = `[NSLayoutConstraint]`\n\n### Equal and Unequal Anchors\nThis constraints the `top-anchor` of the view to the `top-anchor` of the superview:\n\n```swift\nview.top(to: superview)\n```\n\nThis constraints the `top-anchor` of `firstView` to the `bottom-anchor` of `secondView`:\n\n```swift\nfirstView.topToBottom(of: secondView)\n```\n\n### Constrain to Superview\nOften you need to constrain a view to it's superview, with TinyConstraints you can do this super easy:\n\n```swift\nview.edgesToSuperview()\n```\n\nOr only one edge:\n\n```swift\nview.topToSuperview()\n```\n\nOr you can attach all edges except one, like this:\n\n```swift\nview.edgesToSuperview(excluding: .bottom)\n```\n\n### Relation and Priority\nFor almost all constraints you can set the `relation` and `priority` properties. The default relation is `.equal` and the default priority is `.required`:\n\n```swift\ncontainer.width(150, relation: .equalOrLess, priority: .high)\n```\n\n### Storing Constraints\nHere we create a set of inactive constraints and store these to our property:\n\n```swift\nlet constraints = view.size(CGSize(width: 100, height: 100), isActive: false)\n```\n\n### Activation and Deactivation\nBesides the default `NSLayoutConstraint` activation, `TinyConstraints` also provides a way to activate *a set* of constraints:\n\n```swift\nconstraints.activate()\n```\n\nYou can also do this in an animation:\n\n```swift\noldConstraints.deActivate()\n\nconstraints.activate()\nUIViewPropertyAnimator(duration: 1, dampingRatio: 0.4) {\n    self.layoutIfNeeded()\n}.startAnimation()\n```\n\n### Animating Constraint Constants\nHere we add a height constraint to a view, store it and animate it later:\n\n```swift\nlet height = view.height(100)\n\nheight.constant = 200\nUIViewPropertyAnimator(duration: 1, dampingRatio: 0.4) {\n    self.layoutIfNeeded()\n}.startAnimation()\n```\n\n### Stack\nStack provides a way of constraining views together in a superview:\n\n```swift\nlet views = [logo, title, description]\nsuperview.stack(views, axis: .vertical, spacing: 10)\n```\n\n##### Find these examples and more in the *Example Project*.\n\n## Installation\n\n### CocoaPods\n\nTinyConstraints is available through [CocoaPods](http:\u002F\u002Fcocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"TinyConstraints\"\n```\n\n### Carthage\n\nTinyConstraints is available through [Carthage](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage). To install\nit, simply add the following line to your Cartfile:\n\n```\ngithub \"roberthein\u002FTinyConstraints\"\n```\n\n### Swift Package Manager\n\nTinyConstraints is available through [Swift Package Manager](https:\u002F\u002Fswift.org\u002Fpackage-manager\u002F). To install\nit, in Xcode 11.0 or later select `File` > `Swift Packages` > `Add Package Dependency...` and add TinyConstraints repository URL:\n```\nhttps:\u002F\u002Fgithub.com\u002Froberthein\u002FTinyConstraints.git\n```\n\n## Tutorials\n\nHere are some [video tutorials](https:\u002F\u002Fwww.youtube.com\u002Fplaylist?list=PL_csAAO9PQ8ZDbGk57RlBRnNpxBGBAEOc) made by [Alex Nagy](https:\u002F\u002Fgithub.com\u002Frebeloper).\n\n\n## Suggestions or feedback?\n\nFeel free to create a pull request, open an issue or find [me on Twitter](https:\u002F\u002Ftwitter.com\u002Froberthein).\n","TinyConstraints 是一个用于简化 iOS 开发中 Auto Layout 使用的 Swift 库。它通过提供更简洁、易读的语法糖来减少代码量，同时保持与标准 Auto Layout 代码的完全兼容性。其核心功能包括默认激活约束、支持设置优先级以及直接对父视图进行约束等。此外，TinyConstraints 还允许开发者以单行代码实现视图堆叠，并自动处理 `translatesAutoresizingMaskIntoConstraints` 属性。此库非常适合需要快速开发且重视代码可维护性的 iOS 项目，在创建复杂用户界面布局时尤为有用。","2026-06-11 03:09:28","top_language"]