Detecting Color of 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?
I want to load corresponding UI skins in case of Black or White devices.
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.
The answer to the question is NO (as of now) and personally I don't think it's worth much, because what if the end-user uses a skin or an additional casing for his iPhone?
I'd suggest to initially ask the user "Hey, what's the color of your phone?" and then do accordingly.
Additionally, a research provided me with this information, I'm not sure if it's TRUE or if is going to help you.
The serial number is the key :)
If aabccdddeef
is the serial number of the iPhone 4, ee
represents the Color, (A4=black). I hope some of you here check this information with yours to see if this is true.
Just my 2 cents worth - if anyone is looking for the iPhone 5c colors, the colors below are picked from the apple website.
Hope it is of use to anyone:-)
iPhone 5c Colors:
Green
R 179
G 243
B 142
HEX #B3F38E
Blue
R 123
G 195
B 252
HEX #7BC3FC
Yellow
R 255
G 243
B 141
HEX #FFF38D
Red
R 252
G 132
B 142
HEX #FF848E
White
R 239
G 239
B 239
HEX #EFEFEF
链接地址: http://www.djcxy.com/p/35120.html
上一篇: 如何在iOS上获取设备型号和型号?