UIDeviceIcon 2.0.0

UIDeviceIcon 2.0.0

theoriginalbit 维护。



  • theoriginalbit

UIDeviceIcon

Language License Pod Version Carthage Compatible

一个 µ 框架,通过扩展 UIDevice 检测并提供一个图标来表示设备型号。同时检测模拟器和它所模拟的设备型号。

安装

CocoaPods

pod 'UIDeviceIcon', '~> 2.0'

Carthage

github "theoriginalbit/UIDeviceIcon"

使用

首先导入框架

import UIDeviceIcon

常见的用法是在 switch 语句中使用

let deviceIcon = UIDevice.current.deviceIcon

switch deviceIcon {
case .deviceIcon(let deviceIcon):
    break // You have a CADeviceLayer (CAShapeLayer), now do with it as you wish!
case .unknown(let deviceIdentifier):
    break // UIDeviceModel was unable to determine what device this identifier matched
case .unsupported(let deviceModel):
    break // UIDeviceIcon does not have an SVG path to represent this device model
}

从版本 1.2 开始,您可以指定屏幕和扬声器的颜色及摄像头和主按钮(如有可用)的颜色。

let deviceIcon: CADeviceLayer = ...

deviceIcon.bezelColor = .white // .fillColor also works
deviceIcon.screenColor = .red
deviceIcon.cameraColor = .green
deviceIcon.speakerColor = .orange
deviceIcon.homeColor = .blue

请查看示例应用程序,以了解实际应用实现。