UILabel设置一段文字不同颜色和不同大小

来源:互联网 发布:膜是什么意思网络语言 编辑:程序博客网 时间:2024/06/09 22:28

//设置不同字体颜色

-(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:NSForegroundColorAttributeNamevalue:vaColorrange:range];

    

    labell.attributedText = str;

}

0 0
原创粉丝点击