How to Detect the Colour of an iPhone 5C

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.

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.

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/

Looking to test iPhone 5C tint colors. Is this available in the iOS Simulator?

Tint of the device casing is not available (publicly) via software, this functionality you're after is not possible. Report an enhancement request via http://bugreport.apple.com

iOS -- detect the color of a pixel?

This may not be the most direct route, but you could:

  1. Use UIGraphicsBeginImageContextWithOptions to grab the screen (see the Apple Q&A QA1703 - "Screen Capture in UIKit Applications").

  2. Then use CGImageCreateWithImageInRect to grab the portion of the resultant image you require.

  3. Finally analyse the resultant image. It gets complicated at this point, but thankfully there's an existing question that should show you the way: How to get the RGB values for a pixel on an image on the iphone

Alternatively, there's the following blog article that has accompanying code: What Color is My Pixel? Image based color picker on iPhone

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;
}

Is there a way to detect if the iPhone is in inverse color mode?

Yes, and it's simple. You can call

UIAccessibilityIsInvertColorsEnabled();

which return a BOOL for whether or not inverted colors is currently on.

You can also observe

UIAccessibilityInvertColorsStatusDidChangeNotification

to get notified when the user turns on or off inverted colors.



Related Topics



Leave a reply



Submit