- (void)setupDiffColorLabel:(UILabel )label WithTitle:(NSString )title WithSeparateString:(NSString )separate WithLeadColor: (UIColor )LeadColor WithTrailColor :(UIColor *)TrailColor
{
label.text = title;
label.textColor = LeadColor;
NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:label.text];
NSRange redRange = NSMakeRange(0, [[noteStr string] rangeOfString:separate].location);
[noteStr addAttribute:NSForegroundColorAttributeName value:TrailColor range:redRange];
[label setAttributedText:noteStr];
}
同一个label设置不同颜色文字
最新推荐文章于 2021-09-09 17:26:29 发布