We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3fce4c7 + 1f443b9 commit a1f0be7Copy full SHA for a1f0be7
Paralayout/PixelRounding.swift
@@ -34,7 +34,17 @@ extension UIScreen: ScaleFactorProviding {
34
extension UIView: ScaleFactorProviding {
35
36
public var pixelsPerPoint: CGFloat {
37
+ let scaleFromTraits = traitCollection.displayScale
38
+
39
+ // The trait collection is the authority for display scale, but sometimes the trait collection does not have a
40
+ // value for the scale, in which case it will return 0, breaking all the things.
41
+ if scaleFromTraits > 0 {
42
+ return scaleFromTraits
43
+ }
44
45
+ #if os(iOS)
46
return (window?.screen ?? UIScreen.main).pixelsPerPoint
47
+ #endif
48
}
49
50
0 commit comments