问题
I am trying to determine whether the device being used is iPhone or iPad.
Please see this question: Detect current device with UI_USER_INTERFACE_IDIOM() in Swift
That solution works if you use UIKit. But
What is the equivalent method if you are using SwiftUI ?
回答1:
you can find the device type, like this:
if UIDevice.current.userInterfaceIdiom == .pad {
}
来源:https://stackoverflow.com/questions/61113923/how-to-detect-current-device-using-swiftui