Skip to content

Instantly share code, notes, and snippets.

@enomoto
Last active May 30, 2023 12:01
Show Gist options
  • Save enomoto/8ecac375f468c56a7e40b3a7af95fd9b to your computer and use it in GitHub Desktop.
Save enomoto/8ecac375f468c56a7e40b3a7af95fd9b to your computer and use it in GitHub Desktop.
iOS display scale
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