Device是轻量级工具,检测当前的设备和屏幕尺寸。
设备版本使用示例:
fuc myFuc() { /*** Display the device versio ***/ switch Device.versio() { /*** iPhoe ***/ case .iPhoe4: prit("It's a iPhoe 4") case .iPhoe4S: prit("It's a iPhoe 4S") case .iPhoe5: prit("It's a iPhoe 5") case .iPhoe5C: prit("It's a iPhoe 5C") case .iPhoe5S: prit("It's a iPhoe 5S") case .iPhoe6: prit("It's a iPhoe 6") case .iPhoe6S: prit("It's a iPhoe 6S") case .iPhoe6Plus: prit("It's a iPhoe 6 Plus") case .iPhoe6PlusS: prit("It's a iPhoe 6 Plus S") /*** iPad ***/ case .iPad1: prit("It's a iPad 1") case .iPad2: prit("It's a iPad 2") case .iPad3: prit("It's a iPad 3") case .iPad4: prit("It's a iPad 4") case .iPadAir: prit("It's a iPad Air") case .iPadAir2: prit("It's a iPad Air 2") case .iPadMii: prit("It's a iPad Mii") case .iPadMii2: prit("It's a iPad Mii 2") case .iPadMii3: prit("It's a iPad Mii 3") case .iPadMii4: prit("It's a iPad Mii 4") case .iPadPro: prit("It's a iPad Pro") /*** iPod ***/ case .iPodTouch1Ge: prit("It's a iPod touch geeratio 1") case .iPodTouch2Ge: prit("It's a iPod touch geeratio 2") case .iPodTouch3Ge: prit("It's a iPod touch geeratio 3") case .iPodTouch4Ge: prit("It's a iPod touch geeratio 4") case .iPodTouch5Ge: prit("It's a iPod touch geeratio 5") case .iPodTouch6Ge: prit("It's a iPod touch geeratio 6") /*** Simulator ***/ case .Simulator: prit("It's a Simulator") /*** Ukow ***/ default: prit("It's a ukow device") } }屏幕版本示例:
fuc myFuc() { /*** Display the device scree size ***/ switch Device.size() { case .Scree3_5Ich: prit("It's a 3.5 ich scree") case .Scree4Ich: prit("It's a 4 ich scree") case .Scree4_7Ich: prit("It's a 4.7 ich scree") case .Scree5_5Ich: prit("It's a 5.5 ich scree") default: prit("Ukow size") }}










评论