swift - Swift - 基于不同尺寸设备的动作
问题描述
我想要实现的是根据他们的设备类型设置不同的操作。
例如:如果我想为 iPhone 8 做不同的事情
if device type is = iPhone 8
{
//action here
...
}
依此类推每个设备
解决方案
我认为你应该使用这个库:
https://github.com/lmirosevic/GBDeviceInfo
使用这个库,您可以编写您要求的代码,并免费获得大量其他功能(获取设备信息)
if (deviceInfo.model == GBDeviceModeliPhone6) {
print("It's an iPhone 6")
}
推荐阅读
- perl - 将 Sentry 与 Mojolicious 集成
- javascript - 如何停止触控板上的当前滑动
- python - Ubuntu中的Python导入模块和文件
- python - 如何协调从 keras flow_from_dataframe 到实际标签的预测?
- c# - 即使在浏览应用程序时,如何在 Xamarin Forms 中单击后临时禁用按钮?
- linux - Linux 进程/组件发送频繁的 DNS 查询以解析本地主机名(但不应该)
- stripe-payments - Stripe 订阅计划测试
- jquery - jQuery Ajax 在为 Wikipedia API 使用 JSON Parse 时抛出错误
- python - 熊猫 - 删除两列彼此相等的行?
- python - Pyglet 纹理不覆盖正方形