文本属性未显示在丰富的UITextView(iOS 6)中

Ste*_*hal 2 iphone uitextview nsattributedstring ios ios6

我正在尝试为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;
Run Code Online (Sandbox Code Playgroud)

sos*_*orn 8

该方法表示dictionaryWithObjectsAndKeys.你已经完成了对象和键的反转.试试这个:

NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
     attributes:[NSDictionary dictionaryWithObjectsAndKeys:
     [UIColor redColor], NSForegroundColorAttributeName, 
     [NSNumber numberWithInt: NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
     nil]];
Run Code Online (Sandbox Code Playgroud)