为什么这段代码在IOS7中不起作用的原因是什么?我试图设置颜色,但颜色不会改变,它会保持黑色:
NSDictionary *attributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];
NSAttributedString *subString = [[NSAttributedString alloc] initWithString:@"abc" attributes:attributes];
UITextView *textView = ....
textView.attributedText = subString;
答案 0 :(得分:0)
使用这个我相信它有效,因为我已经测试了
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil];
NSAttributedString *subString = [[NSAttributedString alloc] initWithString:@"abc" attributes:attributes];