We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sizeInches
First of all thanks for your work on this library :)
If I'm not mistaken, since sizeInches only looks at the screen's height, it can be wrong about the device's size in some situations.
height
For example, a 12.9" iPad Pro in landscape mode happens to have a "height" of 1024, which results in sizeInches returning 9.7.
1024
9.7
As another example, a 9.7" iPad in landscape mode has a "height" of 768, which results in sizeInches returning nil.
768
nil
Is this known or by design? Maybe there's a way of correctly getting device size in landscape mode?
For reference, here's the code computing sizeInches:
extension Screen { public var sizeInches: Double? { switch (height, scale) { case (480, _): return 3.5 case (568, _): return 4.0 case (667, 3.0), (736, _): return 5.5 case (667, 1.0), (667, 2.0): return 4.7 case (812, 3.0): return 5.8 case (896, 2.0): return 6.1 case (896, 3.0): return 6.5 case (1024, _): return ipadSize1024() case (1080, _): return 10.2 case (1112, _): return 10.5 case (1133, _): return 8.3 case (1180, _): return 10.9 case (1194, _): return 11.0 case (1366, _): return 12.9 default: return nil } } func ipadSize1024() -> Double { let deviceModel = UIDevice().dc.deviceModel switch deviceModel { case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadMini5: return 7.9 case .iPadPro10_5Inch: return 10.5 default: return 9.7 } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
First of all thanks for your work on this library :)
If I'm not mistaken, since
sizeInches
only looks at the screen'sheight
, it can be wrong about the device's size in some situations.For example, a 12.9" iPad Pro in landscape mode happens to have a "
height
" of1024
, which results insizeInches
returning9.7
.As another example, a 9.7" iPad in landscape mode has a "
height
" of768
, which results insizeInches
returningnil
.Is this known or by design? Maybe there's a way of correctly getting device size in landscape mode?
For reference, here's the code computing
sizeInches
:The text was updated successfully, but these errors were encountered: