Skip to content

Commit

Permalink
修复plus机型判断问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Mar 9, 2022
1 parent 5b7f86a commit 7e56ab4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = B9D8DJR5J5;
DEVELOPMENT_TEAM = 8G74YECJ4Z;
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -429,7 +429,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = B9D8DJR5J5;
DEVELOPMENT_TEAM = 8G74YECJ4Z;
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
19 changes: 18 additions & 1 deletion Sources/Screen/UIAdapter.Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ extension UIAdapter {
extension UIAdapter.Screen {

public static var isZoomedMode: Bool {
UIScreen.main.scale != UIScreen.main.nativeScale
guard !isPlus else { return UIScreen.main.bounds.width == 375 }
return UIScreen.main.scale != UIScreen.main.nativeScale
}

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

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

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

public static var current: Inch {
guard !isPlus else {
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
return ._5_5
}

switch (nativeSize.width / scale, nativeSize.height / scale, scale) {
case (320, 480, 2):
return ._3_5
Expand Down Expand Up @@ -208,6 +216,11 @@ extension UIAdapter.Screen {
case full

public static var current: Level {
guard !isPlus else {
// Plus 机型比较特殊 下面公式无法正确计算出尺寸
return .regular
}

switch (nativeSize.width / scale, nativeSize.height / scale) {
case (320, 480):
return .compact
Expand All @@ -223,6 +236,10 @@ extension UIAdapter.Screen {
}
}
}

private static var isPlus: Bool {
return nativeSize.equalTo(.init(width: 1080, height: 1920))
}
}

extension UIAdapter.Screen {
Expand Down
2 changes: 1 addition & 1 deletion UIAdapter.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "UIAdapter"
s.version = "1.0.0"
s.version = "1.1.0"
s.summary = "iOS屏幕适配工具"

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

0 comments on commit 7e56ab4

Please sign in to comment.