UILabel *label = [[UILabel alloc] init]; label.text = @"UILabel多种字体"; UIFont *font = [UIFont systemFontOfSize:14]; UIColor *color = [UIColor redColor]; NSRange range = NSMakeRange(0, 1); //设置不同字体颜色 NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:label.text]; //设置字体 [attrStr addAttribute:NSFontAttributeName value:font range:range]; //设置颜色 [attrStr addAttribute:NSForegroundColorAttributeName value:color range:range]; label.attributedText = attrStr;
时间: 2024-12-29 01:58:24