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.

2
  • 1
    Are you looking for NSAttributedString? Commented Aug 1, 2013 at 15:23
  • 1
    Take a look at NSAttributedString, and this link: stackoverflow.com/questions/3586871/… Commented Aug 1, 2013 at 15:25

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.