Răsfoiți Sursa

Use UIApplication instead of UIScreen.main on iOS 13.0 and later

hyun99999 2 ani în urmă
părinte
comite
d2eaf56373
1 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 9 1
      Sources/Views/AnimatedImageView.swift

+ 9 - 1
Sources/Views/AnimatedImageView.swift

@@ -268,7 +268,15 @@ open class AnimatedImageView: UIImageView {
             #if os(visionOS)
             #if os(visionOS)
             let targetSize = bounds.scaled(UITraitCollection.current.displayScale).size
             let targetSize = bounds.scaled(UITraitCollection.current.displayScale).size
             #else
             #else
-            let targetSize = bounds.scaled(UIScreen.main.scale).size
+            var scale: CGFloat = 0
+            
+            if #available(iOS 13.0, *) {
+                let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
+                scale = windowScene?.screen.scale ?? .zero
+            } else {
+                scale = UIScreen.main.scale
+            }
+            let targetSize = bounds.scaled(scale).size
             #endif
             #endif
             let animator = Animator(
             let animator = Animator(
                 frameSource: frameSource,
                 frameSource: frameSource,