{"id":13696112,"url":"https://github.com/netyouli/WHC_AutoLayoutKit","last_synced_at":"2025-05-03T14:31:01.343Z","repository":{"id":56729093,"uuid":"52773310","full_name":"netyouli/WHC_AutoLayoutKit","owner":"netyouli","description":"iOS and Mac OS X platforms currently in use the fastest the simplest development to build the UI layout automatically open source library, strong dynamic layout constraint handling capacity，iOS/Mac OS X平台上使用简单动态布局约束处理能力","archived":false,"fork":false,"pushed_at":"2021-04-13T13:58:00.000Z","size":14580,"stargazers_count":865,"open_issues_count":1,"forks_count":150,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-04-04T05:59:24.395Z","etag":null,"topics":["autocellheight","autolayout","masnory","uistackview","whc"],"latest_commit_sha":null,"homepage":"http://www.wuhaichao.com","language":"Objective-C","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/netyouli.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":"2016-02-29T07:44:09.000Z","updated_at":"2025-03-22T23:08:46.000Z","dependencies_parsed_at":"2022-08-16T00:40:17.766Z","dependency_job_id":null,"html_url":"https://github.com/netyouli/WHC_AutoLayoutKit","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2FWHC_AutoLayoutKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2FWHC_AutoLayoutKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2FWHC_AutoLayoutKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2FWHC_AutoLayoutKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netyouli","download_url":"https://codeload.github.com/netyouli/WHC_AutoLayoutKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252203166,"owners_count":21710901,"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":["autocellheight","autolayout","masnory","uistackview","whc"],"created_at":"2024-08-02T18:00:36.376Z","updated_at":"2025-05-03T14:30:56.300Z","avatar_url":"https://github.com/netyouli.png","language":"Objective-C","funding_links":[],"categories":["Objective-C","Swift","UI Frameworks"],"sub_categories":[],"readme":"# WHC_AutoLayout\n\u003cdiv align=center\u003e\u003cimg src=\"https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/WHC_AutoLayoutLogo.png\" width = \"319.5\" height = \"129\"/\u003e\u003c/div\u003e\u003c/br\u003e\n\n![Build Status](https://api.travis-ci.org/netyouli/WHC_AutoLayoutKit.svg?branch=master)\n[![Platform](https://img.shields.io/cocoapods/p/WHC_AutoLayoutKit.svg?style=flat)](https://github.com/netyouli/WHC_AutoLayoutKit)\n[![Pod Version](http://img.shields.io/cocoapods/v/WHC_AutoLayoutKit.svg?style=flat)](http://cocoadocs.org/docsets/WHC_AutoLayoutKit/)\n[![Pod License](http://img.shields.io/cocoapods/l/WHC_AutoLayoutKit.svg?style=flat)](https://opensource.org/licenses/MIT)\n\n-  iOS and Mac OS X platforms currently in use the fastest the simplest development to build the UI layout automatically open source library, strong dynamic layout constraint handling capacity\n-  Service to update constraints, convenient and quick dynamic UI layout.\n\n**Swift4.+ version** 👉 [WHC_Layout](https://github.com/netyouli/WHC_Layout)\n\n**修改ios11安全布局机制增加whc_IsSafe控制api**\n**布局api内部自动支持兼容处理iphonex头部齐刘海和底部黑线**\n\n**添加UILayoutGuide，safeAreaLayoutGuide约束支持**\n\n**添加抗拉伸和抗压缩api支持链式调用**\n\nIntroduce\n==============\n-  Adopt chain layout Api calls convenient\n-  Include one line of code to calculate UITableViewCell highly module\n-  Contains WHC_StackView module (UIStackView purpose alternative system)\n-  Automatic identification of the same type conflict and update the new constraints\n-  Support change constraints priority\n-  Support delete constraints\n-  Support iOS and Mac OS X\n-  Automatic covering and modify the conflict with type constraints\n\nRequire\n==============\n* iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+\n* Xcode 8.0 or later\n\nNote\n==============\n- When the view call **removeFromSuperview**  the view must call **whc_ResetConstraints** to clear the cache constraint\n\nInstall\n==============\n* CocoaPods: pod 'WHC_AutoLayoutKit'\n\nUsage\n==============\n\n## UILayoutGuide，safeAreaLayoutGuide\n```objective-c\nUILayoutGuide * guide = UILayoutGuide.new;\nUIView * view = UIView.new;\n\nguide.whc_LeftSpace(10)\n.whc_TopSpaceToView(0, self.view.safeAreaLayoutGuide)\n.whc_RightSpace(10)\n.whc_Height(30);\n\nview.whc_LeftSpace(10)\n.whc_RightSpace(10)\n.whc_TopSpaceToView(0, guide)\n.whc_Height(50);\n\n```\n\n## Automatic height view\n![](https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/autoHeight.gif)\n\n```objective-c\nview.whc_LeftSpace(10)\n    .whc_TopSpace(10)\n    .whc_RightSpace(10)\n    .whc_HeightAuto();\n```\n\n## Use lessEqual or greaterEqual (width \u003c= 100 \u0026\u0026 width \u003e= 20)\n```objective-c\nview.whc_Width(100).whc_LessOrEqual()\n    .whc_Width(20).whc_GreaterOrEqual()\n```\n\n## Masonry/SnapKit update the constraint way unfriendly\n```objective-c\n[view mas_updateConstraints:^(MASConstraintMaker *make) {\n    make.top.equalTo(superview.mas_top).with.offset(10); \n    make.left.equalTo(superview.mas_left).with.offset(20);\n    make.bottom.equalTo(superview.mas_bottom).with.offset(-10);\n    make.right.equalTo(superview.mas_right).with.offset(-10);\n}];\n```\n\n## Update the view constraints\nModify the view to the left from 20 other views\n```objective-c\nview.whc_LeftSpace(20);\n// or\nview.whc_LeftSpaceToView(20,otherView);\n```\n\n## Can be directly modified constraints on the Xib and Storyboard\nIf the view of xib leading now amended as left constraints\n```objective-c\n/// First remove the xib view of leading and then add new constraints\nview.whc_RemoveLayoutAttrs(NSLayoutAttributeLeading)\n    .whc_LeftSpace(10);\n```\n\n## Remove the constraint\n\nRemove all constraints associated with view left\n```objective-c\nview.whc_RemoveLayoutAttrs(NSLayoutAttributeLeft);\n```\nTo remove multiple constraints associated with view\n```objective-c\nview.whc_RemoveLayoutAttrs(NSLayoutAttributeLeft,NSLayoutAttributeLeading,NSLayoutAttributeTop);\n// or \nview.whc_RemoveTo(linkView, attrs: NSLayoutAttributeLeft ...);\n```\n\n## Modify the view constraint priority\n\nModify the view constraint for low priority right\n```objective-c\nview.whc_RightSpace(10)\n    .whc_PriorityLow();\n```\n\n```objective-c\n// The higher the priority, the less likely to be stretched\n// 设置抗拉伸优先级,优先级越高越不容易被拉伸\nlabel.whc_ContentHuggingPriority(UILayoutPriorityDefaultLow, UILayoutConstraintAxisHorizontal);\n\n// 设置抗压缩优先级,优先级越高越不容易被压缩\n// Compression priority, the higher the priority the less easy to be compressed\nlabel.whc_ContentCompressionResistancePriority(UILayoutPriorityDefaultLow, UILayoutConstraintAxisHorizontal);\n```\n\n## One line of code calculation cell height\n\nNo reuse way calculated cell height\n```objective-c\n- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {\n    return [UITableViewCell whc_CellHeightForIndexPath:indexPath tableView:tableView];\n}\n```\n\nReuse way calculated cell height\n```objective-c\n- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {\n    return [UITableViewCell whc_CellHeightForIndexPath:indexPath \n                                             tableView:tableView \n                                            identifier:@\"kFirendsCircleCellIdentifier\" \n                                           layoutBlock:^(UITableViewCell *cell) {\n         /// use model layout cell\n         [(FriendsCircleCell *)cell setFriendModel:_friendModelArray[indexPath.row]];\n    }];\n}\n```\n## Use WHC_StackView\n\nCreate WHC_StackView\n```objective-c\nWHC_StackView * stackView = [WHC_StackView new];\n[self.view addSubview: stackView];\n```\n\nAdd constraint\n```objective-c\nstackView.whc_LeftSpace(10)\n         .whc_TopSpace(10)\n         .whc_RightSpace(10)\n         .whc_HeightAuto();\n```\n\nConfiguration stackView\n\n**1.** Set the padding\n```objective-c\nstackView.whc_Edge = UIEdgeInsetsMake(10, 10, 10, 10); // 内边距\n```\n**2.** Set the layout direction\n```objective-c\nstackView.whc_Orientation = Vertical;                  // 自动垂直布局\n```\n**3.** Set the child views lateral clearance\n```objective-c\nstackView.whc_HSpace = 10;                             // 子视图横向间隙\n```\n**4.** Set the child views vertical clearance\n```objective-c\nstackView.whc_VSpace = 10;                             // 子视图垂直间隙\n```\n**5.** Add subview and start the layout \n```objective-c\nfor (int i = 0; i \u003c 4; i++) {\n    UIView * view = [UIView new];\n    [stackView addSubview:view];        \n}\n[stackView whc_StartLayout];\n```\nPrompt\n==============\n\nFor more UI layout automatically, WHC_StackView components, one line of code to calculate the cell height module, please download this demo to check the specific usage\n\nPart of the WHC_AutoLayoutKit demo show\n==============\n\u003cimg src = \"https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/c.png\" width = \"375\"\u003e\u003cimg src = \"https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/g.png\" width = \"375\"\u003e\n![](https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/f.gif)![](https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/a.gif)![](https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/swiftb.gif)![image](https://github.com/netyouli/WHC_AutoLayoutKit/blob/master/Gif/d.png)\n\nLicenses\n==============\nAll source code is licensed under the MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetyouli%2FWHC_AutoLayoutKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetyouli%2FWHC_AutoLayoutKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetyouli%2FWHC_AutoLayoutKit/lists"}