HLDevice
参考了DeviceKit,用于判断 iOS 设备型号:
HLDeviceModel
:用于判断设备模型,如iPhoneX等HLDeviceType
: 用于判断设备类型,目前有三种:HLDeviceTypeUnkown
: 未知设备,HLDeviceTypeRealMachine
: 真机,HLDeviceTypeSimulator
: 模拟器modelIdentifier
: iOS 设备识别符。 如: "iPhone1,1", "iPad1,1"等
安装
CocoaPods
pod 'HLDevice'
手动
将 HLDevice.h
和 HLDevice.m
拖到工程中即可。
使用方法
HLDevice *device = [HLDevice currentDevice];
if (device.deviceModel == HLDeviceModeliPhoneX ) {
...
}
[HLDevice currentDevice]
为单例对象,如果工程中对该设备对象使用次数很少,可以使用下面的正常实例化方法:
HLDevice *device = [[HLDevice alloc] init];
if (device.deviceModel == HLDeviceModeliPhoneX ) {
...
}
历史
- 2020-11-17 添加对
iPhone SE2
和iPhone 12
系列、以及iPad 7
、iPad 8
、iPad Air 4
和iPad Pro
2020 系列的支持 - 2019-09-27 添加对
iPhone 11
系列、iPad Air 3
、iPad mini 5
和iPod Touch 7
的支持 - 2019-01-23 更新iPad型号
- 2018-10-09 修复真机bug。
- 2018-09-29 增加三种设备类型: iPhoneXR, iPhoneXS, iPhoneXS Max