欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IOS中一段文字設(shè)置多種字體顏色代碼

 更新時間:2015年05月27日 16:54:31   投稿:hebedich  
這篇文章主要介紹了IOS中一段文字設(shè)置多種字體顏色代碼,十分的實(shí)用,有需要的小伙伴可以參考下。

給定range和需要設(shè)置的顏色,就可以給一段文字設(shè)置多種不同的字體顏色,使用方法如下:

復(fù)制代碼 代碼如下:

[self fuwenbenLabel:contentLabel FontNumber:[UIFont systemFontOfSize:15] AndRange:NSMakeRange(6, 1) AndColor:RGBACOLOR(34, 150, 253, 1)];

復(fù)制代碼 代碼如下:

//設(shè)置不同字體顏色
-(void)fuwenbenLabel:(UILabel *)labell FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor
{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:labell.text];
    //設(shè)置字號
    [str addAttribute:NSFontAttributeName value:font range:range];
    //設(shè)置文字顏色
    [str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
    labell.attributedText = str;
}

以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。

相關(guān)文章

最新評論