我想将选取框标签放在 UITableView 单元格中,但是像标签文本一样定制的颜色不同
我正在使用 MarqueeLabel 类,我能够在 UITableViewCell 上显示该 Marquee 标签,并且它非常有效。
我也尝试过 NSAttributedString 但 MarqueeLabel 不支持不同颜色的标签文本
如果有人有答案,请给我
谢谢。
这是我的代码
[cell.contentView addSubview:[self createMarqueeLabelWithIndex:indexPath.row]];
[cell.textLabel setTextColor:[UIColor redColor] range:NSMakeRange(4, 3)];
-(MarqueeLabel *)createMarqueeLabelWithIndex:(int)index
{
MarqueeLabel *continuousLabel2 = [[MarqueeLabel alloc] initWithFrame:CGRectMake(10,0,300,30) rate:50.0f andFadeLength:10.0f];
continuousLabel2.marqueeType = MLContinuous;
continuousLabel2.continuousMarqueeSeparator = @"";
continuousLabel2.animationCurve = UIViewAnimationOptionCurveLinear;
continuousLabel2.numberOfLines = 1;
continuousLabel2.opaque = NO;
continuousLabel2.enabled = YES;
continuousLabel2.shadowOffset = CGSizeMake(0.0, -1.0);
continuousLabel2.textAlignment = UITextAlignmentLeft;
continuousLabel2.backgroundColor = [UIColor clearColor];
continuousLabel2.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.000];
NSString *strText = [[arrTicker objectAtIndex:index] objectForKey:@"text"];
NSString *strTime = [[arrTicker objectAtIndex:index] objectForKey:@"time"];
NSString *strUser = [[arrTicker objectAtIndex:index] objectForKey:@"userid"];
NSString *strTemp = [NSString stringWithFormat:@"%@ %@ %@ ",strText,strTime,strUser];
continuousLabel2.text = [NSString stringWithFormat:@"%@",strTemp];
return continuousLabel2;
}