检测 iPhone/iPad/iPod touch 的颜色? [英] Detecting Color of iPhone/iPad/iPod touch?

查看:35
本文介绍了检测 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 来检索 DeviceColorDeviceEnclosureColor.

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:

http://www.futuretap.com/blog/device-colors/

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

这篇关于检测 iPhone/iPad/iPod touch 的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆