本文介绍了检测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:

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

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

08-16 06:38