NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"總共%@題",numStr]];
[str addAttribute:NSForegroundColorAttributeName value:DOMINICAL_COLOR range:NSMakeRange(0,2)];
[str addAttribute:NSForegroundColorAttributeName value:SHALLOW_GREEN_COLOR range:NSMakeRange(2,numStr.length)];
[str addAttribute:NSForegroundColorAttributeName value:DOMINICAL_COLOR range:NSMakeRange(2+numStr.length,1)];
UILabel *titleLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(5, CGRectGetMaxY(lineView.frame)+5, 100, 20)];
titleLabel3.backgroundColor = [UIColor clearColor];
titleLabel3.font = MBLACK15_FONT;
titleLabel3.attributedText = str;
[self addSubview:titleLabel3];
Label文字多種顏色
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.