enum Device {
//MARK:当前设备类型 iphone iPad Mac
enum Devicetype{
case iphone,ipad,mac
}
static var deviceType:Devicetype{
#if os(macOS)
return .Mac
#else
if UIDevice.current.userInterfaceIdiom == .pad {
return .iPad
}
else {
return .iPhone
}
#endif
}
参考博客:
在SwiftUI下对iPad进行适配 - 简书