Browse Source

Merge pull request #2157 from onevcat/hyun99999-master

Use trait collection to determine scale
Wei Wang 2 years ago
parent
commit
66a7ff7fd8
1 changed files with 8 additions and 1 deletions
  1. 8 1
      Sources/Views/AnimatedImageView.swift

+ 8 - 1
Sources/Views/AnimatedImageView.swift

@@ -268,7 +268,14 @@ open class AnimatedImageView: UIImageView {
             #if os(visionOS)
             let targetSize = bounds.scaled(UITraitCollection.current.displayScale).size
             #else
-            let targetSize = bounds.scaled(UIScreen.main.scale).size
+            var scale: CGFloat = 0
+            
+            if #available(iOS 13.0, tvOS 13.0, *) {
+                scale = UITraitCollection.current.displayScale
+            } else {
+                scale = UIScreen.main.scale
+            }
+            let targetSize = bounds.scaled(scale).size
             #endif
             let animator = Animator(
                 frameSource: frameSource,