Skip to content

Commit 34347f4

Browse files
committed
修复plus机型判断问题
1 parent e13548f commit 34347f4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

AutoInch.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "AutoInch"
4-
s.version = "2.4.0"
4+
s.version = "2.4.1"
55
s.summary = "优雅的iPhone 等比例/精准 适配工具"
66

77
s.homepage = "https://github.com/lixiang1994/AutoInch"

Sources/Screen.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ extension ScreenWrapper {
9898
public enum Screen {
9999

100100
public static var isZoomedMode: Bool {
101-
UIScreen.main.scale != UIScreen.main.nativeScale
101+
guard !isPlus else { return UIScreen.main.bounds.width == 375 }
102+
return UIScreen.main.scale != UIScreen.main.nativeScale
102103
}
103104

104105
static var size: CGSize {
@@ -123,6 +124,7 @@ public enum Screen {
123124
case _428 = 428
124125

125126
public static var current: Width {
127+
guard !isPlus else { return ._414 }
126128
return Width(rawValue: nativeSize.width / scale) ?? .unknown
127129
}
128130
}
@@ -139,6 +141,7 @@ public enum Screen {
139141
case _926 = 926
140142

141143
public static var current: Height {
144+
guard !isPlus else { return ._736 }
142145
return Height(rawValue: nativeSize.height / scale) ?? .unknown
143146
}
144147
}
@@ -156,6 +159,11 @@ public enum Screen {
156159
case _6_7 = 6.7
157160

158161
public static var current: Inch {
162+
guard !isPlus else {
163+
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
164+
return ._5_5
165+
}
166+
159167
switch (nativeSize.width / scale, nativeSize.height / scale, scale) {
160168
case (320, 480, 2):
161169
return ._3_5
@@ -200,6 +208,11 @@ public enum Screen {
200208
case full
201209

202210
public static var current: Level {
211+
guard !isPlus else {
212+
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
213+
return .regular
214+
}
215+
203216
switch (nativeSize.width / scale, nativeSize.height / scale) {
204217
case (320, 480):
205218
return .compact
@@ -215,6 +228,10 @@ public enum Screen {
215228
}
216229
}
217230
}
231+
232+
private static var isPlus: Bool {
233+
return nativeSize.equalTo(.init(width: 1080, height: 1920))
234+
}
218235
}
219236

220237
extension Screen {

0 commit comments

Comments
 (0)