Device.swift 1.2.2

Device.swift 1.2.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2019年2月
SPM支持 SPM

Johannes SchicklingCody WintonIgor Kislyuk 维护。



  • 作者:
  • Johannes Schickling, Cody Winton 和 Igor Kislyuk

Device.swift

Language License Platform Documentation Pod Version Carthage Compatible

一个用于检测使用的设备的轻量级库

Device.swift 通过添加一个属性扩展了 UIDevice

var deviceType: DeviceType

安装

Carthage

将以下内容添加到您的 Cartfile 中,然后按照 这些说明 进行操作

github "schickling/Device.swift"

CocoaPods

要集成 Device 到您的项目中,请将以下内容添加到您的 Podfile

platform :ios, '8.0'
use_frameworks!

pod 'Device.swift'

使用

import Device

// Use import Device_swift if you're using Cocoapods

let deviceType = UIDevice.current.deviceType

switch deviceType {
  case .iPhone6SPlus: print("Do stuff for iPhone6S Plus")
  case .iPadMini: print("Do stuff for iPad mini")
  default: print("Check other available cases of DeviceType")
}

此外,请参阅我们的文档