我正在尝试为iOS 6 UITextView中的某些初始文本设置字体颜色。在UI 6模拟器中运行时,视图会出现,但不会呈现属性。我错过了什么吗?
NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
NSForegroundColorAttributeName, [UIColor redColor] ,
NSUnderlineStyleAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle],nil]
];
_descriptionView.attributedText = as;
答案 0 :(得分:8)
该方法表示dictionaryWithObjectsAndKeys。你已经完成了对象和键的反转。试试这个:
NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
nil]];