swiftUI ipad适配

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进行适配 - 简书

猜你喜欢

转载自blog.csdn.net/baidu_40537062/article/details/127501591