如何讓一個lable展現不一樣的文字風格

NSString *str_one =[NSString stringWithFormat:@"當前成功掃描%lu箱瓶蓋",(unsigned long)a ];
                NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:str_one];
                [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,6)];
                [str addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(6, [[str string] rangeOfString:str_one].length - 9)];
                [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange([[str string]rangeOfString:str_one].length -3 , 3)];
                
                
                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25.0] range:NSMakeRange(0, 6)];
                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30.0] range:NSMakeRange(6, [[str string] rangeOfString:str_one].length - 9)];
                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25.0] range:NSMakeRange([[str string]rangeOfString:str_one].length -3 , 3)];

                _lab_buttom.attributedText = str ;
相關文章
相關標籤/搜索