-1

I have a TextView in which I need some text to change colors and fonts. Any method is available other than core text. Please help.

DarkAjax
  • 15,175
  • 11
  • 52
  • 65
Deepak
  • 1,228
  • 3
  • 14
  • 23

1 Answers1

3

i need some text to change colors and fonts.

You certainly looking for NSAttributedString


From Source

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Hello. That is a test attributed string."];
[str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(20, 10)];
label.attributedText = str;
Community
  • 1
  • 1
Anoop Vaidya
  • 45,475
  • 15
  • 105
  • 134