diff --git a/AutoInch.podspec b/AutoInch.podspec index 716a08a..275b55e 100644 --- a/AutoInch.podspec +++ b/AutoInch.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "AutoInch" -s.version = "2.4.0" +s.version = "2.4.1" s.summary = "优雅的iPhone 等比例/精准 适配工具" s.homepage = "https://github.com/lixiang1994/AutoInch" diff --git a/Sources/Screen.swift b/Sources/Screen.swift index ddab209..a235e03 100644 --- a/Sources/Screen.swift +++ b/Sources/Screen.swift @@ -98,7 +98,8 @@ extension ScreenWrapper { public enum 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 } static var size: CGSize { @@ -123,6 +124,7 @@ public enum Screen { case _428 = 428 public static var current: Width { + guard !isPlus else { return ._414 } return Width(rawValue: nativeSize.width / scale) ?? .unknown } } @@ -139,6 +141,7 @@ public enum Screen { case _926 = 926 public static var current: Height { + guard !isPlus else { return ._736 } return Height(rawValue: nativeSize.height / scale) ?? .unknown } } @@ -156,6 +159,11 @@ public enum 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 @@ -200,6 +208,11 @@ public enum 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 @@ -215,6 +228,10 @@ public enum Screen { } } } + + private static var isPlus: Bool { + return nativeSize.equalTo(.init(width: 1080, height: 1920)) + } } extension Screen {