NSAttributedString修改字符串颜色

应用中有一个滚动条,根据滚动条的值显示下面的字符串:
Very Bad, Bad, Okay, Good, Very Good

滚动条的实现代码如下:

  - (IBAction) sliderValueChanged:(UISlider *)sender {
   scanLabel.text = [NSString stringWithFormat:@" %.f", [sender value]];
    NSArray *texts=[NSArray arrayWithObjects:@"Very Bad", @"Bad", @"Okay", @"Good", @"Very Good", @"Very Good", nil];
    NSInteger sliderValue=[sender value]; //make the slider value in given range integer one.
    self.scanLabel.text=[texts objectAtIndex:sliderValue];
}

其中Very Bad红色,Bad橙色,Okay黄色,Good和Very Good绿色。不知道怎么设置attributedstring实现?谢谢

我还没编译:

NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:self.text.text];
NSRange range=[self.text.text rangeOfString:[texts objectAtIndex:sliderValue]];

NSArray *colors=[NSArray arrayWithObjects:[UIColor redColor],[UIColor redColor],[UIColor yellowColor],[UIColor greenColor],nil];

[string addAttribute:NSForegroundColorAttributeName value:[colors objectAtIndex:sliderValue] range:range];           

[self.scanLabel setAttributedText:[texts objectAtIndex:sliderValue]];