标签:
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"我还是一样帅"];
//设置文字颜色
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(4, 1)];
//设置字体
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(1, 3)];
UILabel *label = [[UILabel alloc]init];
label.frame =CGRectMake(100, 200, 200, 50);
label.attributedText =str;
[self .view addSubview:label];
改变字符形状和颜色NSMutableAttributedString
标签:
原文地址:http://www.cnblogs.com/dyyios/p/4490648.html