5

can anyone tell me how can i change the color of part of uilabel string with some generic method??

let me explain ..

i have label like

  "10/05/2008 4 years",
  "10/05/2011 2 years",
  "20/06/1933 - 07/07/1970 37 years",
  "10/05/1982 30 years",
  "10/05/2008 4 years",
  "10/05/2011 2 years",
  "20/06/1933 - 07/07/1970 37 years"

now what i want is to make years and its value e.g(4 years) in diffrent color and date in diffrent color with difrent font.

NSMutableAttributedString * string = [[NSMutableAttributedString alloc]initWithString:peopleDate.text];
    [string addAttribute:NSForegroundColorAttributeName value:GraycolorForText range:NSMakeRange(10, 5)];
    [peopleDate setAttributedText:string];

this will just change the color with in the particular range and its not generic..so can any one please give me any solution??

BhavikKama
  • 8,566
  • 12
  • 94
  • 164
  • Possible duplicate of [UILabel with text of two different colors](https://stackoverflow.com/questions/6501808/uilabel-with-text-of-two-different-colors) – Dorad Jul 04 '17 at 05:00

0 Answers0