Created
December 5, 2022 05:29
-
-
Save gewill/55df11194e5e469555a9718cdf565366 to your computer and use it in GitHub Desktop.
UserInterfaceIdiom for all Apple platforms or devices.
This file contains 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
enum UserInterfaceIdiom: Int { | |
case unspecified = -1 | |
case phone = 0 | |
case pad = 1 | |
case tv = 2 | |
case carPlay = 3 | |
case mac = 5 | |
case watch = 6 | |
static var current: UserInterfaceIdiom { | |
#if os(iOS) | |
UserInterfaceIdiom(rawValue: UIDevice.current.userInterfaceIdiom.rawValue) ?? .unspecified | |
#elseif os(macOS) | |
return .mac | |
#elseif os(watchOS) | |
return .watch | |
#elseif os(tvOS) | |
return .tv | |
#else | |
return .unspecified | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment