富文本的简单运用,可以改变文字的字体 颜色
UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 300, 220, 30)];
testLabel.backgroundColor = [UIColor lightGrayColor];
testLabel.textAlignment = NSTextAlignmentCenter;
NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:@"测试一下富文本"];
[attributedStr addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:26.0]
range:NSMakeRange(2, 3)];
[attributedStr addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(2, 2)];
testLabel.attributedText = attributedStr;
[self.view addSubview:testLabel];