代碼如下
NSMutableAttributedString *attributedString1 = [[NSMutableAttributedString alloc]initWithString:Label.text];[attributedString1 addAttribute:NSForegroundColorAttributeName value:BuleTextColor range:NSMakeRange(0,20)];Label.attributedText = attributedString1;真機運行后全局斷點斷在了 [attributedString1 addAttribute:NSForegroundColorAttributeName value:BuleTextColor range:NSMakeRange(0,20)];這句代碼
報錯原因是:range長度越界 解決辦法:檢查Label.text的長度是否達到20
新聞熱點
疑難解答
圖片精選