I have these Views on which I add UILabels as text, The Views can have a background color that is dynamic and cannot be chosen,
Based on that I need to figure out the font color from only a set of three choices - two black or white or dark grey.
For example on a dark red background, a white font would be more suitable than black, while on a light yellow, perhaps a dark grey or black would be readable,
is there any index i could check from the background UIColor to see the illuminance?
Select the text you're interested in. Right click on the text and choose Font from the context menu (or just hit ctrl-D) Click the down arrow to the right of the Font color setting, then click More Colors. Click the Custom tab, and you'll see the RGB value of the colour.
Detailed Solution. The correct answer is Shading. For the color background of the text in a document, select the text and choose a color as per requirement.
Change the color of text If you don't see text controls, tap Cell or Text. Tap Text Color, then choose one of the following: A color or gradient designed to go with the template: Tap Preset, swipe left or right to see all the choices, then tap a color.
Once installed, open the Messages app start a new iMessage. In the menu above the keyboard and select "Color". Select "Type Custom Message", and type your message in the bubble. From the color bubble (highlighed below), select from a range of colors to change text background color on iPhone.
Take a look at my UIColor
category and the blackOrWhiteContrastingColor
method. This will tell you what will look better out of black or white. You could extend that to support dark grey as well.
Basically the way it works is to look at the luminosity difference between the target colour and black, and then between the target colour and white. It then chooses the biggest luminosity difference.
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