0

I'm basically trying to manipulate the string to have the Game Review portion either bold or a different color from the variable passed in as it's basically passing it all as the same size/color. Anyway to manipulate this in the same line or? What are my options? I was thinking of just having a static label Game Review and a separate label to pass this in that's set a different color/font but is there an alternative?

Here is the code I'm basically trying to manipulate:

NSString *gName = [NSString stringWithFormat:@"Game Review: %@",[aVideoGame name]];

itemView.gameName.text = gName;

Basically wanting Game Review bold, while the info passed in [aVideoGame name] isn't. Not sure what to do here, as I'm a n00b.

peko
  • 11,267
  • 4
  • 33
  • 48
user2122206
  • 51
  • 1
  • 1
  • 8

2 Answers2

1

You can use NSAttributedString and add attributes to each section of the string (addAttribute:value:range:), then set the attributedText of the label.

Wain
  • 118,658
  • 15
  • 128
  • 151
0

It seems you basically want an NSAttributedString and it's mutable friend, NSMutableAttributedString. Several APIs, such as UILabel's attributedText can deal with it, but you can also easily render it yourself. Be sure to read the Attributed String Programming Guide, even though it talks mostly about the Mac, almost all of it also applies to iOS.

DarkDust
  • 90,870
  • 19
  • 190
  • 224