UILabel設置一段文字不同顏色和不同大小

//設置不同字體顏色

-(void)fuwenbenLabel:(UILabel *)labell FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor

{

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:labell.text];

    

    //設置字號

    [str addAttribute:NSFontAttributeName value:font range:range];

    

    //設置文字顏色

    [str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];

    

    labell.attributedText = str;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章