1

Display unicode characters in a UILabel as follows:

NSString *str = @"flag \u2691 and heart \u2764";
myUILabel.text = str;

The flag is displayed in black and white, while the heart is displayed in red with gradual change. So the question is: is it possible to control the color of unicode characters?

dda
  • 6,030
  • 2
  • 25
  • 34
lu yuan
  • 7,207
  • 9
  • 44
  • 78

1 Answers1

2

Take a look at OHAttributedLabel. It allows you to style your text label with more than 1 color. (Also lets you have different fonts in one label)

shabbirv
  • 8,958
  • 4
  • 33
  • 34
  • Yes, I know this class, but I wander if it could implemented with UILabel. Thx for your reply:) – lu yuan Jun 03 '12 at 07:52
  • It's not possible to use have more than one color with UILabel unfortunately – shabbirv Jun 03 '12 at 07:53
  • maybe it's possible with unicode characters, such as the heart displayed in red with gradual change. – lu yuan Jun 03 '12 at 07:54
  • 2
    Thanks for mentionning my OHAttributedLabel class ;) And no these colored characters are emoji glyphs so are a very special case (the color is included in Apple's glyph representation of this special emoji character) – AliSoftware Jun 03 '12 at 13:49