FutureTap - Smart iPhone Apps

The FutureBlog

October 11, 2013 by Ortwin Gentz

Retrieve iOS device colors

I recently came across a private API to find out the hardware device color of iPhone, iPad and iPod touch. There are two color values, the DeviceColor (front side) and the DeviceEnclosureColor (bezel/back side). The latter is not supplied in all cases. Here’s the code to retrieve these values:

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"]);
}

In a joint effort, we collected the values for most devices (thanks to all contributors!).

Peter Maurer finally mentioned the file system location for artwork of the various iOS devices:

/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MobileDevices.bundle/Contents/Resources/

With this knowledge at hand I decided to write a small demo app that displays the artwork and the device colors and lets you share them. Unfortunately, this uses a private API, so don’t use this in App Store builds as your app will get rejected!

Nevertheless I can imagine various interesting use cases to match the interface UI with the hardware color. So if you’d like to see this in a public API, feel free to dupe my radar.