NSAttributedString在IOS7中不工作UITextVIew

时间:2013-10-05 18:57:25

标签: ios7 uitextview uicolor nsattributedstring

为什么这段代码在IOS7中不起作用的原因是什么?我试图设置颜色,但颜色不会改变,它会保持黑色:

NSDictionary *attributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];
NSAttributedString *subString = [[NSAttributedString alloc] initWithString:@"abc" attributes:attributes];

UITextView *textView = ....

textView.attributedText = subString;

1 个答案:

答案 0 :(得分:0)

使用这个我相信它有效,因为我已经测试了

    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil];
    NSAttributedString *subString = [[NSAttributedString alloc] initWithString:@"abc" attributes:attributes];