{"id":15037525,"url":"https://github.com/lfkdsk/justuikit","last_synced_at":"2025-04-09T23:24:23.514Z","repository":{"id":56917060,"uuid":"79231306","full_name":"lfkdsk/JustUiKit","owner":"lfkdsk","description":"iOS UI Kit With Android-Style Tools. JustUiKit contains JustLinearLayout, JustFrameLayout and so on. It is designed to make Android developers build iOS UI easily. Also for iOS developers, it provides a new way to build UI.","archived":false,"fork":false,"pushed_at":"2017-02-21T09:41:13.000Z","size":214,"stargazers_count":37,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T16:54:44.677Z","etag":null,"topics":["android-style","cocoapods","swift-library","swift3","ui-kit","uiview"],"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/lfkdsk.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-01-17T13:40:40.000Z","updated_at":"2024-07-10T15:24:11.000Z","dependencies_parsed_at":"2022-08-21T03:50:50.503Z","dependency_job_id":null,"html_url":"https://github.com/lfkdsk/JustUiKit","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfkdsk%2FJustUiKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfkdsk%2FJustUiKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfkdsk%2FJustUiKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfkdsk%2FJustUiKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lfkdsk","download_url":"https://codeload.github.com/lfkdsk/JustUiKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248127181,"owners_count":21052203,"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":["android-style","cocoapods","swift-library","swift3","ui-kit","uiview"],"created_at":"2024-09-24T20:34:54.742Z","updated_at":"2025-04-09T23:24:23.493Z","avatar_url":"https://github.com/lfkdsk.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JustUiKit\niOS UI Kit With Android-Style Tools. JustUiKit contains `JustLinearLayout`, `JustFrameLayout` and so on. It is designed to make Android developers build iOS UI easily. Also for iOS developers, it provides a new way to build UI.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/lfkdsk/JustUiKit/master/LICENSE)\n[![](https://img.shields.io/badge/JustUiKit-v0.1.4-green.svg)](https://github.com/lfkdsk/JustUiKit)\n[![](https://img.shields.io/badge/support-iOS8%2B-green.svg)](https://github.com/lfkdsk/JustUiKit)\n[![CocoaPods](https://img.shields.io/cocoapods/v/JustUiKit.svg?style=flat-square)](https://cocoapods.org/pods/JustUiKit)\n\n[中文请参阅](README_ZH.md)\n\n## How To Install?\n\n* Copy to your project\n\n​       Copy JustUiKit folder from the demo project to your project\n\n* Installation with CocoaPods\n\n  CocoaPods is a dependency manager for Objective-C/Swift, which automates and simplifies the process of using 3rd-party libraries like JustUiKit in your projects. You can install it with the following command:\n\n  `$ sudo gem install cocoapods`\n\n  To integrate JustUiKit into your Xcode project using CocoaPods, specify it in your Podfile:\t\n\n  ``` ruby\n  platform :ios, '8.0'\n  pod 'JustUiKit', '~\u003e 0.2.1'\n  ```\n\n  ​Then, run the following command:\n\n  `$ pod install`\n\n## Quick Start\n\n### JustLinearLayout\nA Layout that arranges its children in a single column or a single row. The direction of the row can be set by `orientation`. You can also specify gravity, which specifies the alignment of all the child elements by set `gravity` or specify that specific children grow to fill up any remaining space in the layout by setting the weight member of `LinearLayoutParams`. The default orientation is horizontal.\n\n#### Gravity \u0026 Margin \u0026 Orientation\n  ![Vertical](art/vertical_layout.png)\n\nYou can set `Gravity` to make Views be layouted at a specify space of parentView. Also set `Margin` will remain spaces in the four directions of the View. In default, LinearLayout layout children in `Horizontal` direction, and you can change it to `Veritcal`.\n\nExample:\n\n``` swift\nlet parentView = JustLinearLayout(frame: UIScreen.main.bounds, orientation: .Vertical)\nlet params = LinearLayoutParams(\n                width: LayoutParams.WRAP_CONTENT,\n                height: LayoutParams.WRAP_CONTENT)\nlet centerParams = LinearLayoutParams(params)\ncenterParams.layoutGravity = Gravity.Horizontal.getValue()\n\nlet marginParams = LinearLayoutParams(params)\nmarginParams.topMargin = 10\n\nparentView.addView(createView(), centerParams)\nparentView.addView(createView(), marginParams)\n```\n\n#### Padding \u0026 weight\n  ![Horizontal](art/horizontal_layout.png)\n\nWith the `Padding` in four directions, you can remain inner space of the view. And `Weight` describes how the child views are positioned. Defaults to Gravity.TOP | Gravity.LEFT. If this layout has a VERTICAL orientation, this controls where all the child views are placed if there is extra vertical space. If this layout has a HORIZONTAL orientation, this controls the alignment of the children.\n\nSee [Gravity](##Gravity) to get more details.\n\nExample:\n\n``` swift\nlet parentView = JustLinearLayout(frame: UIScreen.main.bounds, orientation: .Vertical)\nlet params = LinearLayoutParams(\n                width: LayoutParams.WRAP_CONTENT,\n                height: LayoutParams.WRAP_CONTENT)\nparams.weight = 1\nlet paddingParams = LinearLayoutParams(params)\npaddingParams.paddingTop = 10\nparentView.addView(createView(), params)\nparentView.addView(createView(), paddingParams)\n```\n\n### JustFrameLayout\n\nFrameLayout is designed to block out an area on the screen to display a single item.\nGenerally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.\nYou can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the layoutGravity.\n\n#### Overlap on left\n![Frame1](art/framelayout1.png)\n\nif don't use any `Margin` or `Padding` to change view's position. All the Views will be add like stack and overlap on the `left|top` of the screen. \n\nExample:\n\n``` swift\nlet parentView: JustFrameLayout = JustFrameLayout(width:MATCH_PARENT, height:MATCH_PARENT)\nlet params: FrameLayoutParams = JustFrameLayoutParams(width: WRAP_CONTENT, height: WRAP_CONTENT)\nparentView.addView(createView(rgb:0xE4E1D8), params)\nparentView.addView(createView(rgb:0x89A49D), params)\nparentView.addView(createView(rgb:0x877B6B), params)\n```\n\n#### Layout With Gravity\n![Frame2](art/framelayout2.png)\n\nYou can use horizontal and vertical gravity. Also You can use like `left|bottom`, `center_horizontal|center_vertical` to use them at the same time.\n\nSee [Gravity](##Gravity) to get more details.\n\nExample:\n\n``` swift\nlet parentView: FrameLayout = FrameLayout(width:MATCH_PARENT, height:MATCH_PARENT)\nlet params: FrameLayoutParams = FrameLayoutParams(width: WRAP_CONTENT, height: WRAP_CONTENT)\n\nlet b_l = FrameLayoutParams(params)\nb_l.layoutGravity = Gravity.BOTTOM | Gravity.TOP\nlet c_r = FrameLayoutParams(params)\nc_r.layoutGravity = Gravity.CENTER_HORIZONTAL | Gravity.RIGHT\nparentView.addView(createView(rgb:0xE4E1D8), b_l)\nparentView.addView(createView(rgb:0x89A49D), c_r)\nparentView.addView(createView(rgb:0x877B6B), params)\n```\n\n### JustRelativeLayout \nA Layout where the positions of the children can be described in relation to each other or to the parent.\n\nNote that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM.\n\n![relative](art/relativelayout1.png)\n\nIn RelativeLayout, you can use all the `Margin`,`Padding` and `Gravity`. Also You can use some `Align` functions. Such as, if a view is `alignLeftTo`, its left edge will be set equal to the anchor view. You can use a set of functions like `leftOf`, `rightOf`, `bottomOf` set the current view to the left of anchor view. \n\n``` swift\n// view1 view2 view3 view4 view5\nlet params = RelativeLayoutParams.generateDefaultParams()\nlet params1 = RelativeLayoutParams(params)\nparams1.centerInHorizontal()\nlet params2 = RelativeLayoutParams(params)\nparams2.bottomTo(view4)\nparams2.topMargin = xxx\nlet params3 = RelativeLayoutParams(params)\nparam3.alignRightTo(view1)\nlet params4 = RelativeLayoutParams(params)\nparams4.centerInParent()\nlet params5 = RelativeLayoutParams(params)\nparams5.alignParentBottom()\n// add view to parent\n```\n\n#### Rule in RelativeLayout\n\n| Constants           | Description                              |\n| ------------------- | ---------------------------------------- |\n| ABOVE               | Rule that aligns a child's bottom edge with another child's top edge. |\n| ALIGN_BASELINE      | Rule that aligns a child's baseline with another child's baseline. |\n| ALIGN_BOTTOM        | Rule that aligns a child's bottom edge with another child's bottom edge. |\n| ALIGN_LEFT          | Rule that aligns a child's left edge with another child's left edge. |\n| ALIGN_PARENT_BOTTOM | Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge. |\n| ALIGN_PARENT_LEFT   | Rule that aligns the child's left edge with its RelativeLayout parent's left edge. |\n| ALIGN_PARENT_RIGHT  | Rule that aligns the child's right edge with its RelativeLayout parent's right edge. |\n| ALIGN_PARENT_TOP    | Rule that aligns the child's top edge with its RelativeLayout parent's top edge. |\n| ALIGN_RIGHT         | Rule that aligns a child's right edge with another child's right edge. |\n| ALIGN_TOP           | Rule that aligns a child's top edge with another child's top edge. |\n| BELOW               | Rule that aligns a child's top edge with another child's bottom edge. |\n| CENTER_HORIZONTAL   | Rule that centers the child horizontally with respect to the bounds of its RelativeLayout parent. |\n| CENTER_IN_PARENT    | Rule that centers the child with respect to the bounds of its RelativeLayout parent. |\n| CENTER_VERTICAL     | Rule that centers the child vertically with respect to the bounds of its RelativeLayout parent. |\n| END_OF              | Rule that aligns a child's start edge with another child's end edge. |\n| LEFT_OF             | Rule that aligns a child's right edge with another child's left edge. |\n| RIGHT_OF            | Rule that aligns a child's left edge with another child's right edge. |\n\n## Gravity\n\nMust be one or more (separated by '|') of the following constant values.\n\n| Constant          | Value | Description                              |\n| :---------------- | ----- | ---------------------------------------- |\n| top               | 0x30  | Push object to the top of its container, not changing its size. |\n| bottom            | 0x50  | Push object to the bottom of its container, not changing its size. |\n| right             | 0x05  | Push object to the right of its container, not changing its size. |\n| center_vertical   | 0x10  | Place object in the vertical center of its container, not changing its size. |\n| center_horizontal | 0x01  | Place object in the horizontal center of its container, not changing its size. |\n| center            | 0x11  | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |\n\n## Feedback\n\nPlease send your feedback as long as there occurs any inconvenience or problem. You can contact me with:\n* Email: lfk_dsk@hotmail.com\n* Weibo: [@亦狂亦侠_亦温文](http://www.weibo.com/u/2443510260)\n* Blog:  [刘丰恺](https://lfkdsk.github.io)\n\n## License\n\n```\n\n    MIT License\n\n    Copyright (c) 2017 JustWe\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfkdsk%2Fjustuikit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfkdsk%2Fjustuikit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfkdsk%2Fjustuikit/lists"}