Ios – Detecting Color of iPhone/iPad/iPod touch

iosiphoneobjective cuidevice

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.

Best Answer

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.