After iPhone 5c announcement, i'm curious if anybody knows an API how to get an iPhone 5c colour? I'm sure everyone will find it convenient loading a corresponding UI colour scheme to the device colour.
I'm thinking about wrapping it in something like the UIDevice category, which will return a UIColor.
Update: @ColinE and @Ortwin Gentz has indicated the availability of private UIDevice instance method calls for it.
Please note, that in case of iPhone 5c, what you are really looking for is deviceEnclosureColor, as deviceColor will always return #3b3b3c, as it is a front colour.
method signature:
-(id)_deviceInfoForKey:(struct __CFString { }*)arg1
UIDevice category for it:
@interface UIDevice (deviceColour)
- (id)_deviceInfoForKey:(struct __CFString { }*)arg1;
- (NSString*)deviceColourString_UntilAppleMakesItPublic;
- (NSString*)deviceEnclosureColour_UntilAppleMakesItPublic;
@end
@implementation UIDevice (deviceColour)
- (NSString*)deviceColourString_UntilAppleMakesItPublic
{
return [self _deviceInfoForKey:@"DeviceColor"];
}
- (NSString*)deviceEnclosureColour_UntilAppleMakesItPublic
{
return [self _deviceInfoForKey:@"DeviceEnclosureColor"];
}
@end
Use the eyedropper tool to pick an exact color from an image on the screen. It can be useful if you want to match a color on the current document or one from another file. It's also handy if you see a color you like and want to save it for later.
Perform the API request with the Get Contents of URL actionIn the Shortcuts app on your iOS or iPadOS device, tap Show More in the Get Contents of URL action. The following options for the types of API requests you can make become available: GET allows you to retrieve data. POST allows you to create new data.
Once activated, a large on-screen menu serves up frequently used functions for easier access and use. From the Accessibility Menu, you can lock your screen, take screenshots, open Google Assistant, Quick Settings, and Notifications, and adjust volume and brightness.
Creating a duplicate copy of an app icon is easy. Find the app in the App Library, then drag a new copy of it onto your Home Screen: Swipe to the App Library at the right edge of all your Home Screens. Look through the various folders or use the Search bar to find the app you want to duplicate.
The device colour (used to?) be encoded in the serial number of the device. I don't have a device to test on with them not officially released yet, but I imagine the solution will be similar to this:
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)
[Source]
There is more information on old techniques here
I would like to point out however, that I expect there isn't a supported method of getting the serial number. Assuming you'd only like to know this information so that you can customise your UI, I'd just put in a user option or ask them to select the colour of their device on first startup (or some other early point in the app-user life)
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.
A number of people on Twitter have cited the following method:
[[UIDevice currentDevice] _deviceInfoForKey:@"DeviceColor"]
Although I have not confirmed it myself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With