Author Topic: Changing colors of individual chars within a string  (Read 2330 times)

sk1989

  • Guest
Changing colors of individual chars within a string
« on: September 06, 2012, 01:20:08 PM »
Hello,

I was wondering if there is a way for you to write a code or some sort of key that will allow you to change individual chars within a longer string?

For example: If 1 long string contains 2 words and I want the first word to be white and the second word to be red.
                  string =  Hello(white) World(red)

Is it possible to do this? Or would I have to make 2 separate labels, each of which having a different color tint to it?

thank you


ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: Changing colors of individual chars within a string
« Reply #1 on: September 06, 2012, 01:55:00 PM »
[ffffff]Hello[-] [ff0000]World[-]

Assuming encoding is enabled for your label (there's a checkbox in the inspector), you can put a hexadecimal RGB value within square brackets to change the color of a string within the label.  A dash within square brackets clears the color back to the default for the label.