Device 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Device 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Device 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
开发语言 Swift 查看源码 »
操作系统 iOS
软件类型 开源软件
所属分类 iOS代码库其他(Others)
开源组织
地区 不详
投 递 者 sikkx
适用人群 未知
收录时间 2015-11-10

软件简介

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 .iPhone6PlusS:  print("It's an iPhone 6 Plus S")
            /*** 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 myFucn() {
        /*** 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")
            default:             print("Unknown size")
        }
}

 

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
3 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部