Swift 2016-09-02 10:57
Swift 检测苹果设备型号和屏幕大小的工具 Device
回复:0 查看:4383 感兴趣:26 赞:0
Swift 检测苹果设备型号和屏幕大小的工具 Device。
示例代码:
//设备型号 func myFunc() { /*** Display the device version ***/ switch Device.version() { /*** iPhone ***/ case .iPhone4: print("It's an iPhone 4") case .iPhone4S: print("It's an iPhone 4S") case .iPhone5: print("It's an iPhone 5") case .iPhone5C: print("It's an iPhone 5C") case .iPhone5S: print("It's an iPhone 5S") case .iPhone6: print("It's an iPhone 6") case .iPhone6S: print("It's an iPhone 6S") case .iPhone6Plus: print("It's an iPhone 6 Plus") case .iPhone6SPlus: print("It's an iPhone 6 S Plus") /*** iPad ***/ case .iPad1: print("It's an iPad 1") case .iPad2: print("It's an iPad 2") case .iPad3: print("It's an iPad 3") case .iPad4: print("It's an iPad 4") case .iPadAir: print("It's an iPad Air") case .iPadAir2: print("It's an iPad Air 2") case .iPadMini: print("It's an iPad Mini") case .iPadMini2: print("It's an iPad Mini 2") case .iPadMini3: print("It's an iPad Mini 3") case .iPadMini4: print("It's an iPad Mini 4") case .iPadPro: print("It's an iPad Pro") /*** iPod ***/ case .iPodTouch1Gen: print("It's a iPod touch generation 1") case .iPodTouch2Gen: print("It's a iPod touch generation 2") case .iPodTouch3Gen: print("It's a iPod touch generation 3") case .iPodTouch4Gen: print("It's a iPod touch generation 4") case .iPodTouch5Gen: print("It's a iPod touch generation 5") case .iPodTouch6Gen: print("It's a iPod touch generation 6") /*** Simulator ***/ case .Simulator: print("It's a Simulator") /*** Unknown ***/ default: print("It's an unknown device") } } //设备尺寸 func myFunc() { /*** Display the device screen size ***/ switch Device.size() { case .Screen3_5Inch: print("It's a 3.5 inch screen") case .Screen4Inch: print("It's a 4 inch screen") case .Screen4_7Inch: print("It's a 4.7 inch screen") case .Screen5_5Inch: print("It's a 5.5 inch screen") case .Screen7_9Inch: print("It's a 7.9 inch screen") case .Screen9_7Inch: print("It's a 9.7 inch screen") case .Screen12_9Inch: print("It's a 12.9 inch screen") default: print("Unknown size") } }
相关开源代码
EFIconFont: 一个用 Swift 实现的 IconFont 封装
Swift Zip文件压缩与解压框架
EFResume - 一个普通的 Swift 简历模板
Swift 优雅的定时器及执行工具库 Each
Swift 解析、格式化及验证国际电话号码工具库 PhoneNumberKit
Swift 版 FlatBuffers(跨平台序列化库)FlatBuffersSwift
Swift 编写的 Github API 客户端 Github.swift
Swift OAuth授权库 SwiftyOAuth
Swift 音频处理库 TempiFFT
iOS通知中心封装库SwiftNotificationCenter