Skip to content

Commit f081afa

Browse files
hyun99999calda
andauthored
Use UITraitCollection.current.displayScale instead of deprecated UIScreen.main.scale (#2216)
Co-authored-by: Cal Stephens <[email protected]>
1 parent cdf8499 commit f081afa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/Public/iOS/LottieAnimationViewBase.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ open class LottieAnimationViewBase: UIView {
3939

4040
var screenScale: CGFloat {
4141
#if os(iOS) || os(tvOS)
42-
UIScreen.main.scale
42+
if #available(iOS 13.0, tvOS 13.0, *) {
43+
return max(UITraitCollection.current.displayScale, 1)
44+
} else {
45+
return UIScreen.main.scale
46+
}
4347
#else // if os(visionOS)
4448
// We intentionally don't check `#if os(visionOS)`, because that emits
4549
// a warning when building on Xcode 14 and earlier.
@@ -79,6 +83,5 @@ open class LottieAnimationViewBase: UIView {
7983
func animationWillEnterForeground() {
8084
// Implemented by subclasses.
8185
}
82-
8386
}
8487
#endif

0 commit comments

Comments
 (0)