Last active
May 30, 2023 12:01
-
-
Save enomoto/8ecac375f468c56a7e40b3a7af95fd9b to your computer and use it in GitHub Desktop.
iOS display scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
print(UITraitCollection.current.displayScale) // 3.0 (if device is iPhone 14.0) | |
print(UIScreen.main.scale) // 3.0 (if device is iPhone 14.0) | |
var pixelLengthForUIKit: CGFloat = { | |
1 / UITraitCollection.current.displayScale | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment