Reputation: 656
I'm trying the set the font color for some initial text in a iOS 6 UITextView. When running in the UI 6 simulator, the view comes up, but the attributes aren't rendered. Am I missing something?
NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
NSForegroundColorAttributeName, [UIColor redColor] ,
NSUnderlineStyleAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle],nil]
];
_descriptionView.attributedText = as;
Upvotes: 2
Views: 1349
Reputation: 14694
The method says dictionaryWithObjectsAndKeys. You've gotten your objects and keys reversed. Try this:
NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
nil]];
Upvotes: 8