Can we tell what colour the iPhone is?

Discussion in 'iOS Programming' started by xArtx, Sep 12, 2013.

  1. xArtx, Sep 12, 2013
    Last edited by a moderator: Sep 12, 2013

    xArtx macrumors 6502a

    Joined:
    Mar 30, 2012
    #1
    I watched Apple's September presentation on Apple TV.
    One question, can we tell what colour the iPhone is?
     
  2. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #2
    I would assume so, since the UI changes the color theme based on the color of the device. I guess it's possible that Apple won't expose this info to us...
     
  3. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #3
    ALways thought the current one should know if it's black or white too,
    just for a background theme.

    Then will come the jailbreak hack to switch colours.
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    I remember reading a few months ago about how to get the home screen image so that your app could have the same frosted glass look that the phone app does. I imagine that's more useful for what you're trying to do than the color of the phone itself, which may, after all, have a case of any color on it, which you certainly wouldn't know. If the color of the exterior of the phone is really necessary, it might be best (and easiest) to just ask the user what color it is.
     
  5. xArtx, Sep 13, 2013
    Last edited by a moderator: Sep 13, 2013

    xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #5
    If the phone knows what colour it is, and iOS is prepared to tell you,
    then asking the user would make you look silly.

    I presume the iOS must know, unless iOS asks the user the colour during their iPhone setup,
    but I think this would make Apple look a little silly too.

    In four apps I still haven't used any stock components (not so much as a button or tab bar),
    so I haven't given iOS any opportunity to use the phone colour (if it was going to) AFAIK.
    by "if it was going to", I mean I don't know if iOS was going to try to tint the
    buttons and other components inside apps or not.


     
  6. LizKat macrumors 68040

    LizKat

    Joined:
    Aug 5, 2004
    Location:
    Catskill Mountains
    #6
    With the 5C I have been hoping the iOS would not only know what color the device is, but also offer (in Settings) to let you switch your matching wallpaper to one of the other colors... along the same idea as changing the case color. Why should it have to be a hack, they should just build it into the Settings options. The 5C is all about color anyway -- the body, the cases-- so they need to open it up and let it be about all the colors on the inside too, i.e. the wallpaper colors.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    This might just be something that is set in the factory. Until one can get a hold of a couple of different colored phones and do some experimenting, I would be leery to presume anything. If one changes the wallpaper color to a different choice, does resetting to factory settings change it back? We'll have to see, I guess.
     
  8. MeFromHere macrumors 6502

    Joined:
    Oct 11, 2012
    #8
    iTunes knows the color of all the supported devices I connect to my Mac. All my iOS devices are black, so I can't do much testing with those. But I have various colors of iPods of several generations; iTunes shows the actual color for all of them.

    I don't know if iTunes is asking the devices what color they are or deriving the color from something else. (The color might be encoded in the serial number, for example.)
     
  9. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #9
    I didn't know that. I would say it is the serial number.
    Doesn't mean we can access it.
     
  10. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #10
    Saw two tweets (1,2) on this subject by @stroughtonsmith. A few responses suggest this may be a private API. Given that, it is likely useless for any app you want to have on the App Store.

    This seems to be limited to iOS 7. The return values are hex strings such as #d7d9d8. Oh yea, had to place the calls into a memory managed object. ARC doesn't like it.

    Code:
     [[UIDevice currentDevice] _deviceInfoForKey:@"DeviceEnclosureColor"];  // Detect back plate color of device.
     [[UIDevice currentDevice] _deviceInfoForKey:@"DeviceColor"];  // Detect white or black iOS device.
     
     
  11. xArtx, Sep 18, 2013
    Last edited: Sep 19, 2013

    xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #11
    Interesting, that means the black & white was not always there?
    I'm going to attempt it, and let them reject it.
    I suppose the hex strings are the component colour values.
    At least we can easily find out exactly what they all are.


    EDIT,,,
    I thought that would be their white, but it actually looks too grey:
    http://html-color-codes.info
    Can't actually try it on a device ATM they have iOS7.
     
  12. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #12
    I wrote an app that runs on my iPhone 5. The attached image looks grayer on my Mac than the iPhone. That site also displays a gray for #e1e4e3 which is whiter on the the iPhone.
     

    Attached Files:

  13. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #13
    I don't think the API is private, because I once searched for a way to figure out if the device is an iPhone or iPad and someone pointed to the currentDevice object filled with information about the device.
     
  14. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #14
    currentDevice is not the private API. It's _deviceInfoForKey. Method names that start with underscores are almost certainly private.
     
  15. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #15
    Can you tell how they are found in the first place?

    I haven't looked in any framework headers, but if we can't use them,
    why would we even be supplied with them?

    It would be interesting to know what is out there for personal apps that aren't destined for the App Store.
     
  16. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #16
    Probably by using Obj-C runtime introspection functions. They allow you to do things like print out all the methods, properties, and iVars that a class or instance have. I used such functions a lot while experimenting with making an Xcode plugin, since I wanted to modify the behavior of various views in Xcode for which I didn't have the source code.
     

Share This Page