Overview
The background color of my iPhone app in the simulator (iMac) looks different from the color on the device (iPhone 3GS).
EDIT (following section has been added)
The following are all different:
I suppose I should go with how it looks on the device.
Questions
To create a color from our palette, we can do it directly by selecting the Assets. xcassets folder (or creating our own . xcassets folder for colors) in the project navigator (Project Navigator). Then we right click and select New Color Set.
SwiftUI only resolves a color to a concrete value just before using it in a given environment. This enables a context-dependent appearance for system defined colors, or those that you load from an Asset Catalog. For example, a color can have distinct light and dark variants that the system chooses from at render time.
Credit goes to @jtbandes for suggesting to send screenshots which led to the solution
I am just answering the question for completeness.
Steps I followed:
My RGB offset (not be followed blindly)
based on my experience, i added the following RGB values to get the color I wanted, it is only rough and worked for me:
Different angles (best to keep it horizontal)
Holding the phone in different angles also gives different shades, keeping it horizontal did give the color
As others have pointed out, this is an issue of Color Spaces.
Two tasks need to be performed:
Task 1
You can use Apple's Digital Color Meter
app to sample the required color, using the Display in sRGB
option, but the output is very limited.
Another option is to use an app like SipIt
(available free on the App Store, last I checked). Make sure you are sampling in the correct color space by performing:
Preferences -> General -> Color Profiles -> sRGB
You can also set your output format (e.g. hex string).
Task 2
In Interface Builder, open the Color window, choose the the second pane, choose "RGB Sliders". Then click on the cog icon to choose the sRGB color profile.
Once done, paste your color value in to the Hex Color #
field
You're done! Your colors should now match.
I am not affiliated with SipIt in any way. But I've been using it for a few years and it is very handy. I'd recommend it to any designer.
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