Detecting Color of iPhone/iPad/iPod touch?

totocaster picture totocaster · Dec 11, 2011 · Viewed 12.2k times · Source

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

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

Answer

Ortwin Gentz picture Ortwin Gentz · Oct 11, 2013

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/

Warning: As mentioned, this is a private API. Don't use this in App Store builds.