# AutoInch - 优雅的iPhone等比例/全尺寸精准适配工具
[![License](https://img.shields.io/cocoapods/l/AutoInch.svg)](LICENSE)
![Swift](https://img.shields.io/badge/Swift-5.2-orange.svg)
![Platform](https://img.shields.io/cocoapods/p/AutoInch.svg?style=flat)
[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-4BC51D.svg?style=flat")](https://swift.org/package-manager/)
[![Carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Cocoapods](https://img.shields.io/cocoapods/v/AutoInch.svg)](https://cocoapods.org)
## [:cn:天朝子民](README_CN.md)
## If you haven't used it, Please use [Rename -> UIAdapter](https://github.com/lixiang1994/UIAdapter).
## If you have used it and want to migrate together, Please check the [migration guide](https://github.com/lixiang1994/AutoInch/blob/master/RENAMEGUIDE.md)
## Features
- [x] Numerical type fast conversion
- [x] Storyboard equal scale adaptation
- [x] Xib equal scale adaptation
- [x] Custom calculation processing
- [x] Quick match for each screen size type
## Installation
**CocoaPods - Podfile**
```ruby
pod 'AutoInch'
```
**Carthage - Cartfile**
```ruby
github "lixiang1994/AutoInch"
```
#### [Swift Package Manager for Apple platforms](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)
Select Xcode menu `File > Swift Packages > Add Package Dependency` and enter repository URL with GUI.
```
Repository: https://github.com/lixiang1994/AutoInch
```
#### [Swift Package Manager](https://swift.org/package-manager/)
Add the following to the dependencies of your `Package.swift`:
```swift
.package(url: "https://github.com/lixiang1994/AutoInch.git", from: "version")
```
## Usage
First make sure to import the framework:
```swift
import AutoInch
```
Here are some usage examples. All devices are also available as simulators:
### Auto
AutoLayout (SnapKit):
```swift
private func setupLayout() {
cardView.snp.makeConstraints { (make) in
make.top.equalTo(16.auto())
make.left.right.equalToSuperview().inset(15.auto())
make.bottom.equalTo(-26.auto())
}
lineView.snp.makeConstraints { (make) in
make.left.right.equalToSuperview().inset(15.auto())
make.top.equalTo(titleLabel.snp.bottom)
make.height.equalTo(1)
}
titleLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview()
make.left.equalTo(15.auto())
make.height.equalTo(48.auto())
}
stateLabel.snp.makeConstraints { (make) in
make.top.equalTo(lineView).offset(10.auto())
make.left.equalTo(15.auto())
make.height.equalTo(15.auto())
}
}
```
Property (Then):
```swift
private lazy var cardView = UIView().then {
$0.cornerRadius = 6.auto()
$0.backgroundColor = .white
}
private lazy var lineView = UIView().then {
$0.backgroundColor = .hex("000000", alpha: 0.05)
}
private lazy var titleLabel = UILabel().then {
$0.textColor = .black
$0.font = .systemFont(ofSize: 20.auto(), weight: .medium)
}
private lazy var stateLabel = UILabel().then {
$0.textColor = .gray
$0.font = .systemFont(ofSize: 12.auto(), weight: .medium)
}
```
Storyboard / Xib:
![Constraint](Resources/Storyboard%20Constraint.png)
![UILabel Font](Resources/Storyboard%20Label%20Font.png)
### Screen
e.g.
```swift
// default other screen numberOfLines = 0
// 3.5 inches screen numberOfLines = 1
// 4.0 inches screen numberOfLines = 2
label.numberOfLines = 0.screen.inch(._3_5, is: 1).inch(._4_0, is: 2).value
```
```swift
// default other screen numberOfLines = 0
// width 320 screen numberOfLines = 1
// width 375 inches screen numberOfLines = 2
label.numberOfLines = 0.screen.width(._320, is: 1).width(._375, is: 2).value
```
```swift
print("this is " +
"default".screen
.width(._320, is: "width 320")
.width(._375, is: "width 375")
.height(._844, is: "height 844")
.height(._812, is: "height 812")
.inch(._4_7, is: "4.7 inches")
.inch(._5_8, is: "5.8 inches")
.inch(._6_5, is: "6.5 inches")
.level(.compact, is: "screen 3: 2")
.level(.regular, is: "screen 16: 9")
.level(.full, is: "screen 19.5: 9")
.value
)
```
## Screenshot
![TikTok 1](Resources/Storyboard%20TikTok%20Demo1.jpg)
![TikTok 2](Resources/Storyboard%20TikTok%20Demo2.jpg)
## Contributing
If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue.
If you extended the functionality of AutoInch yourself and want others to use it too, please submit a pull request.
## License
AutoInch is under MIT license. See the [LICENSE](LICENSE) file for more info.
>### [相关文章 Inch](https://www.jianshu.com/p/d2c09cb65ef7)
>### [相关文章 Auto](https://www.jianshu.com/p/e0e12206e0c7)
>### [相关文章 Auto](https://www.jianshu.com/p/48c67d0c95b6)
-----
> ## 欢迎入群交流
![QQ](https://github.com/lixiang1994/Resources/blob/master/QQClub/QQClub.JPG)
没有合适的资源?快使用搜索试试~ 我知道了~
优雅的iPhone全尺寸等比例精准合适的配件_Swift_Ruby_下载.zip
共78个文件
png:22个
json:15个
swift:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 127 浏览量
2023-04-22
16:15:36
上传
评论
收藏 1MB ZIP 举报
温馨提示
优雅的iPhone全尺寸等比例精准合适的配件_Swift_Ruby_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
优雅的iPhone全尺寸等比例精准合适的配件_Swift_Ruby_下载.zip (78个子文件)
AutoInch-master
.swiftpm
xcode
package.xcworkspace
contents.xcworkspacedata 135B
README_CN.md 5KB
AutoInch.podspec 569B
Package.swift 978B
AutoInch.xcodeproj
xcshareddata
xcschemes
AutoInch.xcscheme 3KB
project.pbxproj 12KB
project.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 153B
LICENSE 1KB
RENAMEGUIDE.md 2KB
AutoInch.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 218B
Sources
AutoInch.h 480B
Screen.swift 8KB
Info.plist 743B
Auto.swift 13KB
Resources
Storyboard TikTok Demo1.jpg 305KB
Storyboard Label Font.png 265KB
Storyboard TikTok Demo2.jpg 384KB
Storyboard Constraint.png 222KB
.gitignore 1KB
Demo
Demo.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 222B
Podfile 123B
Demo.xcodeproj
xcshareddata
xcschemes
Demo.xcscheme 3KB
project.pbxproj 19KB
project.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 195B
Demo
Utils
StoryBoard.swift 953B
Then.swift 3KB
Base.lproj
Main.storyboard 11KB
LaunchScreen.storyboard 2KB
TikTok
Controller
TikTokPasswordLoginViewController.swift 8KB
TikTokPhoneLoginViewController.swift 8KB
Storyboard
TikTok.storyboard 91KB
AppDelegate.swift 2KB
ViewController.swift 2KB
NavigationController.swift 2KB
Info.plist 2KB
Assets.xcassets
Contents.json 62B
TikTok
tiktok_textfield_clear.imageset
Plist
PhoneCountryCode.dataset
Contents.json 165B
PhoneCountryCode.plist 5KB
Contents.json 62B
tiktok_sign_loading.imageset
Contents.json 62B
tiktok_sign_done.imageset
tiktok_arrow_down.imageset
tiktok_icon_wechat.imageset
tiktok_back.imageset
tiktok_close.imageset
tiktok_icon_qq.imageset
tiktok_icon_sina.imageset
tiktok_icon_toutiao.imageset
AppIcon.appiconset
Contents.json 2KB
Podfile.lock 265B
README.md 5KB
Tests
AutoInchTests
AutoInchTests.swift 376B
共 78 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功