利用iOS7的label特性对abel进行封装使用
对一段字符串当中的某段进行颜色变化,直接掉用加方法就可以显示
```
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UILabel *labelDemo = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 300, 40)]; [self.view addSubview:labelDemo]; NSString *originalString = @"今天是:星期日"; NSString *changeString = @"星期日"; labelDemo.attributedText = [ViewController changeLabelColorOriginalString:originalString changeString:changeString]; } + (NSMutableAttributedString *)changeLabelColorOriginalString:(NSString *)originalString changeString:(NSString *)changeString { NSRange changeStringRange = [originalString rangeOfString:changeString]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:originalString]; [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:changeStringRange]; return attributedString; }
```
}