Author Topic: Cannot set UILabel Color/ Gradient Colors  (Read 5187 times)

20andup

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Cannot set UILabel Color/ Gradient Colors
« on: June 08, 2014, 11:51:10 PM »
I can set the UILabel color when I use static colours such as Color.black, but when I use a custom color by instantiating a new color, it doesn't work properly

  1.  public void SetTextColor (Color color)
  2.     {
  3.         label.applyGradient = false;
  4.         label.color = color;
  5.         label.MarkAsChanged ();
  6.     }
  7.  
  8.     public void SetTextColorGradient (Color fromColor, Color toColor)
  9.     {
  10.         label.gradientTop = fromColor;
  11.         label.gradientBottom = toColor;
  12.         label.applyGradient = true;
  13.         label.MarkAsChanged ();
  14.     }

At the moment, when say fromColor has rgb of 250, 40, 0, it will set an rgb of an enormous number such as 34232,23423, 2349.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cannot set UILabel Color/ Gradient Colors
« Reply #1 on: June 09, 2014, 03:23:25 AM »
Right, because Color is specified as floating point values ranging from 0 to 1, not 0 to 255. Use Color32 if you're specifying values from 0 to 255.