Detecting Color of iPhone/iPad/iPod touch?
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.
How to detect the colour of an iPhone 5c?
There's a private API to retrieve both the DeviceColor
and the DeviceEnclosureColor
. In case of the iPhone 5c, the interesting part is the enclosure color (the device color = front color is always #3b3b3c).
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.
Get iPhone color iOS Sdk
You can obtain color from model part number, for example:
MD381 - black iPhone 4S
MC920 - white iPhone 4S
...
To obtain model number use uidevice-extension
Addition:
Alternative solution. Link your project with libLockdown.dylib.
extern id lockdown_connect();
extern id lockdown_copy_value(id, id, id);
extern void lockdown_disconnect();
extern NSString *kLockdownDeviceColorKey;
NSString* CopyDeviceColor() {
id connection = lockdown_connect();
NSString *color = lockdown_copy_value(connection, nil, kLockdownDeviceColorKey);
NSLog(@"color = %@", color);
lockdown_disconnect(connection);
return color;
}
iPhone/iPad enclosure color programmatically
As far I as know, you may be able to determine the color of the phone based off the serial number of the device as discussed here: Detecting Color of iPhone/iPad/iPod touch?
I think your best bet it is to show different models of the phone in different colors then ask the user to pick one.
Good luck.
Differentiate between black and white iPhones?
The serial number on the iPhone gives you all this info, you just need to map the code for colour to the colour itself.
Typical format of the iPhone SN is as follows: AABCCDDDEEF
AA = Factory and Machine ID
B = Year of Manufacturing (9 is 2009/2019, 0 is 2010/2020, 1 is 2011 and so on)
CC = Production Week (01 is week 1 of B, 11 is week 11 of B and so on)
DDD = Unique Identifier
EE = Color (A4=black)
F = size (S=16GB, T=32GB)
More info: http://www.pressbyte.com/640/decode-iphone-hardware-information-serial-number/
Detect iDevice color
Model numbers are the way to do, for example:
MD381 - Black iPhone 4S
MC920 - White iPhone 4S
Related Topics
Uicollectionview - Dynamic Cell Height
Looping a Video With Avfoundation Avplayer
How to Use Protocol as Associatedtype in Another Protocol in Swift
Iphone Get a List of All Ssids Without Private Library
How to Get the Day of the Week With Foundation
Detect When an iOS App Is Launched For the First Time
Reloaddata() of Uitableview With Dynamic Cell Heights Causes Jumpy Scrolling
Delete Keychain Items When an App Is Uninstalled
Event Handling For iOS - How Hittest:Withevent: and Pointinside:Withevent: Are Related
How to Detect Orientation Change
How to Remove Empty Cells in Uitableview
Nslog on Devices in iOS 10/Xcode 8 Seems to Truncate - Why
Resizing Uitableview to Fit Content
How to See Saved Nsuserdefaults
Anyobject Not Working in Xcode8 Beta6