同一个label内设置不用字体和颜色

如何这一个label实现不同字体颜色,而不用多个label来实现

如 篮球39

// 距品牌上线差

    NSString *str = [NSString stringWithFormat:@"距品牌上线差%@",@"255"];

    NSMutableAttributedString *attriStr = [[NSMutableAttributedString alloc] initWithString:str];

    [attriStr addAttribute:NSForegroundColorAttributeName value:kRgb(251, 80, 81, 1) range:NSMakeRange(6,3)];

    [attriStr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:11] range:NSMakeRange(6, 3)];

    yourLabel.attributedText = attriStr;


你可能感兴趣的:(同一个label内设置不用字体和颜色)