{"id":20087978,"url":"https://github.com/lixiang1994/uiadapter","last_synced_at":"2025-07-09T13:40:47.204Z","repository":{"id":41263927,"uuid":"415767184","full_name":"lixiang1994/UIAdapter","owner":"lixiang1994","description":"An elegant solution to the iOS screen adaptation problem","archived":false,"fork":false,"pushed_at":"2024-09-26T09:45:45.000Z","size":1045,"stargazers_count":64,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T10:14:18.316Z","etag":null,"topics":["ios","iphone","screenadapter","swift"],"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/lixiang1994.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-11T03:32:08.000Z","updated_at":"2025-02-28T15:25:16.000Z","dependencies_parsed_at":"2024-11-13T21:02:43.105Z","dependency_job_id":null,"html_url":"https://github.com/lixiang1994/UIAdapter","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"641078eecf7160d5398c1de67efbe9a104939646"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FUIAdapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FUIAdapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FUIAdapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FUIAdapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lixiang1994","download_url":"https://codeload.github.com/lixiang1994/UIAdapter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589870,"owners_count":21129693,"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":["ios","iphone","screenadapter","swift"],"created_at":"2024-11-13T16:10:57.861Z","updated_at":"2025-04-12T15:33:02.621Z","avatar_url":"https://github.com/lixiang1994.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UIAdapter - An elegant solution to the iOS screen adaptation problem\n\n[![License](https://img.shields.io/cocoapods/l/UIAdapter.svg)](LICENSE)\u0026nbsp;\n![Swift](https://img.shields.io/badge/Swift-5.2-orange.svg)\u0026nbsp;\n![Platform](https://img.shields.io/cocoapods/p/UIAdapter.svg?style=flat)\u0026nbsp;\n[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-4BC51D.svg?style=flat\")](https://swift.org/package-manager/)\u0026nbsp;\n[![Carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\u0026nbsp;\n[![Cocoapods](https://img.shields.io/cocoapods/v/UIAdapter.svg)](https://cocoapods.org)\n\n## [:cn:天朝子民](README_CN.md)\n\n## Features\n\n- [x] Numerical type fast conversion\n- [x] Storyboard equal scale adaptation \n- [x] Xib equal scale adaptation \n- [x] Custom calculation processing\n- [x] Quick match for each screen size type\n\n\n## Installation\n\n**CocoaPods - Podfile**\n\n```ruby\npod 'UIAdapter'\n```\n\n**Carthage - Cartfile**\n\n```ruby\ngithub \"lixiang1994/UIAdapter\"\n```\n\n#### [Swift Package Manager for Apple platforms](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)\n\nSelect Xcode menu `File \u003e Swift Packages \u003e Add Package Dependency` and enter repository URL with GUI.  \n```\nRepository: https://github.com/lixiang1994/UIAdapter\n```\n\n#### [Swift Package Manager](https://swift.org/package-manager/)\n\nAdd the following to the dependencies of your `Package.swift`:\n```swift\n.package(url: \"https://github.com/lixiang1994/UIAdapter.git\", from: \"version\")\n```\n\n## Usage\n\nFirst make sure to import the framework:\n\n```swift\nimport UIAdapter\n```\n\nHere are some usage examples. All devices are also available as simulators:\n\n\n### Zoom\n\n\nAutoLayout (SnapKit): \n\n```swift\nprivate func setupLayout() {\n    cardView.snp.makeConstraints { (make) in\n\tmake.top.equalTo(16.zoom())\n\tmake.left.right.equalToSuperview().inset(15.zoom())\n\tmake.bottom.equalTo(-26.zoom())\n    }\n\t\n    lineView.snp.makeConstraints { (make) in\n\tmake.left.right.equalToSuperview().inset(15.zoom())\n\tmake.top.equalTo(titleLabel.snp.bottom)\n\tmake.height.equalTo(1)\n    }\n        \n    titleLabel.snp.makeConstraints { (make) in\n        make.top.equalToSuperview()\n        make.left.equalTo(15.zoom())\n        make.height.equalTo(48.zoom())\n    }\n        \n    stateLabel.snp.makeConstraints { (make) in\n        make.top.equalTo(lineView).offset(10.zoom())\n        make.left.equalTo(15.zoom())\n        make.height.equalTo(15.zoom())\n    }\n}\n```\n\nProperty (Then):\n\n```swift\nprivate lazy var cardView = UIView().then {\n    $0.cornerRadius = 6.zoom()\n    $0.backgroundColor = .white\n}\n\nprivate lazy var lineView = UIView().then {\n    $0.backgroundColor = .hex(\"000000\", alpha: 0.05)\n}\n\nprivate lazy var titleLabel = UILabel().then {\n    $0.textColor = .black\n    $0.font = .systemFont(ofSize: 20.zoom(), weight: .medium)\n}\n\nprivate lazy var stateLabel = UILabel().then {\n    $0.textColor = .gray\n    $0.font = .systemFont(ofSize: 12.zoom(), weight: .medium)\n}\n```\n\nStoryboard / Xib:\n\n![Constraint](Resources/Storyboard%20Constraint.png)\n![UILabel Font](Resources/Storyboard%20Label%20Font.png)\n\n### Screen\n\ne.g.\n\n```swift\n// default other screen numberOfLines = 0\n// 3.5 inches screen numberOfLines = 1\n// 4.0 inches screen numberOfLines = 2\nlabel.numberOfLines = 0.screen.inch(._3_5, is: 1).inch(._4_0, is: 2).value\n```\n\n\n```swift\n// default other screen numberOfLines = 0\n// width 320 screen numberOfLines = 1\n// width 375 screen numberOfLines = 2\nlabel.numberOfLines = 0.screen.width(equalTo: 375, is: 1).width(equalTo: 375, is: 2).value\n```\n\n\n```swift\nprint(\"this is \" + \"default\".screen\n    .width(equalTo: 375, is: \"width equal to 375\")\n    .width(lessThan: 414, is: \"width less than 414\")\n    .width(greaterThan: 414, is: \"width greater than 414\")\n    .height(equalTo: 700, is: \"height equal to 375\")\n    .height(lessThan: 844, is: \"height less than 844\")\n    .height(greaterThan: 844, is: \"height greater than 844\")\n    .inch(._4_7, is: \"4.7-inch\")\n    .inch(._5_8, is: \"5.8-inch\")\n    .inch(._6_5, is: \"6.5-inch\")\n    .level(.compact, is: \"screen (4:3)\")\n    .level(.regular, is: \"screen (16:9)\")\n    .level(.full, is: \"screen (19.5:9)\")\n    .value\n)\n```\n\n\n## Screenshot\n\n![TikTok 1](Resources/Storyboard%20TikTok%20Demo1.jpg)\n\n![TikTok 2](Resources/Storyboard%20TikTok%20Demo2.jpg)\n\n## Contributing\n\nIf you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue.\nIf you extended the functionality of UIAdapter yourself and want others to use it too, please submit a pull request.\n\n\n## License\n\nUIAdapter is under MIT license. See the [LICENSE](LICENSE) file for more info.\n\n\n\u003e### [相关文章 Inch](https://www.jianshu.com/p/d2c09cb65ef7)\n\u003e### [相关文章 Auto](https://www.jianshu.com/p/e0e12206e0c7)\n\u003e### [相关文章 Auto](https://www.jianshu.com/p/48c67d0c95b6)\n\n-----\n\n\u003e ## 欢迎入群交流\n![QQ](https://github.com/lixiang1994/Resources/blob/master/QQClub/QQClub.JPG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixiang1994%2Fuiadapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flixiang1994%2Fuiadapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixiang1994%2Fuiadapter/lists"}