UILable 设置不同字体大小和颜色

        NSString * str = @"的时间烦死了贷款福克斯看地方水电费可是烦死了的开发";

        NSAttributedString * str1 = [[NSAttributedString alloc] initWithString:str];

        NSMutableAttributedString * text1 = [[NSMutableAttributedString alloc] initWithAttributedString:str1];

        [text1 addAttribute:NSForegroundColorAttributeName

                      value:UIColorFromRGB(0xfe4299)

                      range:NSMakeRange(0, money.length)];

        [text1 addAttribute:NSFontAttributeName

                      value:[UIFont fontWithName:@"Helvetica-Bold" size:12]

                      range:NSMakeRange(0, money.length)];

        lable.attributedText = text1;

猜你喜欢

转载自blog.csdn.net/u013857988/article/details/79077073
今日推荐