Skip to content

Commit

Permalink
优化Screen, 增加不同UIScreen支持, 增加iPhone 16系列支持.
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Sep 26, 2024
1 parent 8891112 commit 3b1a441
Show file tree
Hide file tree
Showing 13 changed files with 636 additions and 427 deletions.
4 changes: 2 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8G74YECJ4Z;
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -431,7 +431,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8G74YECJ4Z;
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
42 changes: 24 additions & 18 deletions Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,39 @@ class ViewController: UITableViewController {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

print(
"this is " +
"default".screen
.width(._320, is: "宽度 320")
.width(._375, is: "宽度 375")
.height(._844, is: "高度 844")
.height(._812, is: "高度 812")
.inch(._4_7, is: "4.7 英寸")
.inch(._5_8, is: "5.8 英寸")
.inch(._6_5, is: "6.5 英寸")
.level(.compact, is: "屏幕级别 紧凑屏")
.level(.regular, is: "屏幕级别 常规屏")
.level(.full, is: "屏幕级别 全面屏")
.value
print("this is " + "default".screen
.width(equalTo: 375, is: "宽度 等于 375")
.width(lessThan: 414, is: "宽度 小于 414")
.width(greaterThan: 414, is: "宽度 大于 414")
.height(equalTo: 700, is: "高度 等于 375")
.height(lessThan: 844, is: "高度 小于 844")
.height(greaterThan: 844, is: "高度 大于 844")
.inch(._4_7, is: "4.7 英寸")
.inch(._5_8, is: "5.8 英寸")
.inch(._6_5, is: "6.5 英寸")
.level(.compact, is: "屏幕级别 紧凑屏 (4:3)")
.level(.regular, is: "屏幕级别 常规屏 (16:9)")
.level(.full, is: "屏幕级别 全面屏 (19.5:9)")
.value
)

// Range用法: 默认值0, 当宽度小于等于375 返回1
print(0.screen.width(...375, is: 1).value)
// Range用法: 默认值0, 当宽度为375至414范围时 返回1
print(0.screen.width(375...414, is: 1).value)
// Range用法: 默认值0, 当屏幕小于5.5英寸时 返回1
print(0.screen.inch(..<5.5, is: 1).value)

// 默认值 0 在3.5英寸的屏幕时返回1, 在4.0英寸的屏幕时返回2
print(0.screen.inch(._3_5, is: 1).inch(._4_0, is: 2).value)
// 默认值 0 在全面屏时返回1, 在6.1英寸的屏幕时返回2
print(0.screen.level(.full, is: 1).inch(._6_1, is: 2).value)
// 默认值 100 在宽度为375级别的屏幕时 正常返回120, 如果为缩放模式则返回110
print(100.screen.width(._375, is: 120, zoomed: 110).value)
print(100.screen.width(equalTo: 375, is: 120, zoomed: 110).value)

print("当前屏幕级别: \(UIAdapter.Screen.Level.current)")
print("是否为全面屏: \(UIAdapter.Screen.isFull)")
print("是否为缩放模式: \(UIAdapter.Screen.isZoomedMode)")
print("当前屏幕级别: \(UIAdapter.Screen.main.level)")
print("是否为全面屏: \(UIAdapter.Screen.main.level.isFull)")
print("是否为缩放模式: \(UIAdapter.Screen.main.isZoomedMode)")
}

override var preferredStatusBarStyle: UIStatusBarStyle {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :ios, '10.0'
platform :ios, '15.6'
inhibit_all_warnings!

target 'Demo' do
Expand Down
10 changes: 5 additions & 5 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- UIAdapter (1.3.0):
- UIAdapter/Privacy (= 1.3.0)
- UIAdapter/Privacy (1.3.0)
- UIAdapter (1.4.0):
- UIAdapter/Privacy (= 1.4.0)
- UIAdapter/Privacy (1.4.0)

DEPENDENCIES:
- UIAdapter (from `../`)
Expand All @@ -11,8 +11,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
UIAdapter: 2c0c81c68b308e3ce8b4363d4f66b0ced8c1812f
UIAdapter: 81dd1efbab6c0d092ac0d02e12a3c6b84e3c3c99

PODFILE CHECKSUM: 0793a3778780a57cf83a43faa9039eedb0b67f7a
PODFILE CHECKSUM: 6c30ea2512eacb7800929df401f020c67f5b94ec

COCOAPODS: 1.15.2
10 changes: 5 additions & 5 deletions Demo/Pods/Local Podspecs/UIAdapter.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Demo/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3b1a441

Please sign in to comment.