检测 iPhone/iPad/iPod touch 的颜色?

编程入门 行业动态 更新时间:2024-10-25 00:33:18
本文介绍了检测 iPhone/iPad/iPod touch 的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有什么方法或技巧可以检测 iOS 安装在什么颜色(黑色/白色)的 iPhone、iPad 或 iPod touch 上?

Is there any way or hack to detect on what color (black / white) iPhone, iPad or iPod touch the iOS is installed?

我想在黑色或白色设备的情况下加载相应的 UI 皮肤.

I want to load corresponding UI skins in case of Black or White devices.

推荐答案

有一个私有 API 来检索 DeviceColor 和 DeviceEnclosureColor.

There's a private API to retrieve both the DeviceColor and the DeviceEnclosureColor.

UIDevice *device = [UIDevice currentDevice]; SEL selector = NSSelectorFromString(@"deviceInfoForKey:"); if (![device respondsToSelector:selector]) { selector = NSSelectorFromString(@"_deviceInfoForKey:"); } if ([device respondsToSelector:selector]) { NSLog(@"DeviceColor: %@ DeviceEnclosureColor: %@", [device performSelector:selector withObject:@"DeviceColor"], [device performSelector:selector withObject:@"DeviceEnclosureColor"]); }

我已经写了关于这个的博客并提供了一个示例应用程序:

I've blogged about this and provide a sample app:

www.futuretap/blog/device-colors/

警告:如前所述,这是一个私有 API.不要在 App Store 版本中使用它.

更多推荐

检测 iPhone/iPad/iPod touch 的颜色?

本文发布于:2023-08-01 15:44:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   iPad   iPhone   touch   iPod

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!