• Stars
    star
    463
  • Rank 94,021 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

优雅的iPhone全尺寸/等比例精准适配工具

AutoInch - 优雅的iPhone等比例/全尺寸精准适配工具

License  Swift  Platform  Swift Package Manager  Carthage  Cocoapods

🇨🇳天朝子民

If you haven't used it, Please use Rename -> UIAdapter.

If you have used it and want to migrate together, Please check the migration guide

Features

  • Numerical type fast conversion
  • Storyboard equal scale adaptation
  • Xib equal scale adaptation
  • Custom calculation processing
  • Quick match for each screen size type

Installation

CocoaPods - Podfile

pod 'AutoInch'

Carthage - Cartfile

github "lixiang1994/AutoInch"

Swift Package Manager for Apple platforms

Select Xcode menu File > Swift Packages > Add Package Dependency and enter repository URL with GUI.

Repository: https://github.com/lixiang1994/AutoInch

Swift Package Manager

Add the following to the dependencies of your Package.swift:

.package(url: "https://github.com/lixiang1994/AutoInch.git", from: "version")

Usage

First make sure to import the framework:

import AutoInch

Here are some usage examples. All devices are also available as simulators:

Auto

AutoLayout (SnapKit):

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):

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 UILabel Font

Screen

e.g.

// 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
// 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
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

TikTok 2

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 file for more info.

相关文章 Inch

相关文章 Auto

相关文章 Auto


欢迎入群交流

QQ

More Repositories

1

LEEAlert

优雅的可自定义 Alert ActionSheet
Objective-C
1,297
star
2

AttributedString

基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Swift
835
star
3

LEETheme

优雅的主题管理库- 一行代码完成多样式切换
Objective-C
816
star
4

NewsDetailsDemo

资讯详情文章页面Demo 内容部分为HTML数据格式 基于WKWebView加载 原生图片加载方式 (支持GIF图片) 支持持久化缓存等
Objective-C
87
star
5

LEECoolButton

一个炫酷的按钮(适用于喜欢 , 点赞 , 收藏等)
Objective-C
74
star
6

VideoTransitionDemo

视频过渡效果演示
Swift
71
star
7

LEEStarRating

星星评分视图控件 支持整颗 , 半颗 , 无限制评分 可自定义分数范围和星星个数等
Objective-C
60
star
8

UIAdapter

An elegant solution to the iOS screen adaptation problem
Swift
53
star
9

PermissionKit

An elegant permission manager written in swift
Swift
36
star
10

ViewControllerDemo

Swift 泛型 UIViewController的View分离演示
Swift
21
star
11

Router

基于URLNavigator抽象的外部URL路由组件 支持任意类型配置 插件机制
Swift
20
star
12

Loading

An elegant loading view written in swift
Swift
20
star
13

SKUFilterDemo

SKUFilter 电商Stock Keeping Unit选择过滤器示例
Swift
20
star
14

Apis

基于URLNavigator抽象的URL路由组件 灵感来自Moya 配置化 插件化.
Swift
17
star
15

Guider

An elegant highlight focus guide written in swift
Swift
10
star
16

Spring

An elegant animation written in swift
Swift
10
star
17

VideoPlayer

Swift
9
star
18

GearAnimationDemo

齿轮动画Demo
Objective-C
8
star
19

AudioPlayer

Swift
7
star
20

SDKit

简洁、高效的iOS开发“一站式”工具库
Objective-C
6
star
21

Alienware-Aurora-R13-Water-Cooling

外置压缩机水冷改装分享
5
star
22

LEEBubble

一个有趣的小气泡
Objective-C
5
star
23

Scanner

二维码扫描Demo
Swift
4
star
24

AsyncLayer

iOS 异步渲染Layer
Swift
3
star
25

IMInterface

Swift
2
star
26

VideoClipDemo

视频剪切Demo
Swift
2
star
27

LinearView

Linear layout view based on UIStackView Use chain encapsulation to quickly build vertical or horizontal layout views.
Swift
2
star
28

Specs

CocoaPods PodSpecs
Ruby
2
star
29

Resources

1
star
30

LEEResume

简历
JavaScript
1
star
31

Delegates

An elegant multiple delegate written in swift
Swift
1
star
32

ghost-lee-theme

Ghost Blog Themes (LEE)
CSS
1
star
33

QQMusicPlayerDemo

音乐播放器示例Demo 参考QQ音乐
Objective-C
1
star