NSMutableAttributedString *strs = [[NSMutableAttributedString alloc] initWithString:str];
NSRange strRange = {0,[strs length]};
[strs addAttribute:NSForegroundColorAttributeName value:colorWithRGBA(81, 81, 81, 1) range:strRange];//字体颜色
[strs addAttribute:NSUnderlineColorAttributeName value:colorWithRGBA(81, 81, 81, 0.6) range:strRange];//下划线颜色
[strs addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
[_tag setAttributedTitle:strs forState:UIControlStateNormal];
_tag.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;//如果字数太长后面用‘...’代替
按钮标题加下划线
最新推荐文章于 2021-01-13 20:30:47 发布