UIButton setAttributedTitle 是部分手机显示颜色错误

199 阅读1分钟

[_familyButton setTitleColor:kColorWithHex(0x1196ED) forState:UIControlStateNormal];//原本设置的颜色 会失效

\

//需要在富文本中加入颜色

\

        NSString * strinng =  @“”;

        NSRange rangeAll = NSMakeRange(0, strinng.length);

        NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:strinng];

        [attributeStr addAttribute:NSForegroundColorAttributeName value:kColorWithHex(0x1196ED) range:rangeAll];

        [attributeStr addAttribute:NSFontAttributeName value:kMainFontSize(8) range:[strinng rangeOfString:@">"]];

        [button setAttributedTitle:attributeStr forState:UIControlStateNormal];