Skip to content

Commit 7e56ab4

Browse files
committed
修复plus机型判断问题
1 parent 5b7f86a commit 7e56ab4

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409
buildSettings = {
410410
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
411411
CODE_SIGN_STYLE = Automatic;
412-
DEVELOPMENT_TEAM = B9D8DJR5J5;
412+
DEVELOPMENT_TEAM = 8G74YECJ4Z;
413413
INFOPLIST_FILE = Demo/Info.plist;
414414
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
415415
LD_RUNPATH_SEARCH_PATHS = (
@@ -429,7 +429,7 @@
429429
buildSettings = {
430430
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
431431
CODE_SIGN_STYLE = Automatic;
432-
DEVELOPMENT_TEAM = B9D8DJR5J5;
432+
DEVELOPMENT_TEAM = 8G74YECJ4Z;
433433
INFOPLIST_FILE = Demo/Info.plist;
434434
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
435435
LD_RUNPATH_SEARCH_PATHS = (

Sources/Screen/UIAdapter.Screen.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ extension UIAdapter {
119119
extension UIAdapter.Screen {
120120

121121
public static var isZoomedMode: Bool {
122-
UIScreen.main.scale != UIScreen.main.nativeScale
122+
guard !isPlus else { return UIScreen.main.bounds.width == 375 }
123+
return UIScreen.main.scale != UIScreen.main.nativeScale
123124
}
124125

125126
public enum Width: CGFloat {
@@ -131,6 +132,7 @@ extension UIAdapter.Screen {
131132
case _428 = 428
132133

133134
public static var current: Width {
135+
guard !isPlus else { return ._414 }
134136
return Width(rawValue: nativeSize.width / scale) ?? .unknown
135137
}
136138
}
@@ -147,6 +149,7 @@ extension UIAdapter.Screen {
147149
case _926 = 926
148150

149151
public static var current: Height {
152+
guard !isPlus else { return ._736 }
150153
return Height(rawValue: nativeSize.height / scale) ?? .unknown
151154
}
152155
}
@@ -164,6 +167,11 @@ extension UIAdapter.Screen {
164167
case _6_7 = 6.7
165168

166169
public static var current: Inch {
170+
guard !isPlus else {
171+
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
172+
return ._5_5
173+
}
174+
167175
switch (nativeSize.width / scale, nativeSize.height / scale, scale) {
168176
case (320, 480, 2):
169177
return ._3_5
@@ -208,6 +216,11 @@ extension UIAdapter.Screen {
208216
case full
209217

210218
public static var current: Level {
219+
guard !isPlus else {
220+
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
221+
return .regular
222+
}
223+
211224
switch (nativeSize.width / scale, nativeSize.height / scale) {
212225
case (320, 480):
213226
return .compact
@@ -223,6 +236,10 @@ extension UIAdapter.Screen {
223236
}
224237
}
225238
}
239+
240+
private static var isPlus: Bool {
241+
return nativeSize.equalTo(.init(width: 1080, height: 1920))
242+
}
226243
}
227244

228245
extension UIAdapter.Screen {

UIAdapter.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 = "UIAdapter"
4-
s.version = "1.0.0"
4+
s.version = "1.1.0"
55
s.summary = "iOS屏幕适配工具"
66

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

0 commit comments

Comments
 (0)