首页 > 解决方案 > Swift - 基于不同尺寸设备的动作

问题描述

我想要实现的是根据他们的设备类型设置不同的操作。

例如:如果我想为 iPhone 8 做不同的事情

if device type is = iPhone 8 
{

//action here
...

}

依此类推每个设备

标签: swiftiphonexcodedevice

解决方案


我认为你应该使用这个库:

https://github.com/lmirosevic/GBDeviceInfo

使用这个库,您可以编写您要求的代码,并免费获得大量其他功能(获取设备信息)

if (deviceInfo.model == GBDeviceModeliPhone6) {
    print("It's an iPhone 6")
}

推荐阅读