在TextView中为文本添加颜色
答
我需要一些文字来改变颜色和字体。
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Hello. That is a test attributed string."];
[str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(20, 10)];
label.attributedText = str;
你想改变所有文本一些文本,对不对? – Dilip 2013-02-26 14:53:12
您应该通过搜索互联网轻松找到问题的答案。 – bdesham 2013-02-26 15:00:39