设置label不同颜色

来源:互联网 发布:二级运动员知乎 编辑:程序博客网 时间:2024/05/21 12:43

 

 NSMutableAttributedString *textColor = [[NSMutableAttributedStringalloc]initWithString:photoSettingLabel.text];

    NSRange rangel = [[textColorstring] rangeOfString:[photoSettingLabel.textsubstringWithRange:NSMakeRange(18,12)]];

    [textColor addAttribute:NSForegroundColorAttributeNamevalue:UIColorFromHex(0xf0d99b)range:rangel];

    [textColor addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:APPDELEGATE.isPad?20:15]range:rangel];

    

    [photoSettingLabel setAttributedText:textColor];

原创粉丝点击