最近发现以前的方法不能用了,更新一下方法
UILabel *introLabel = [UILabel new];
[lineView addSubview:introLabel];
introLabel.sd_layout
.leftSpaceToView(selBtn,10)
.centerYEqualToView(selBtn)
.widthIs(150)
.heightIs(14);
NSString *str = @"是否准守安全协议";
introLabel.textColor = RGBA(103,103, 103, 1);
introLabel.font = [UIFont systemFontOfSize:14];
[introLabel setAttributedText:[self changeLabelWithText:str]];
introLabel.userInteractionEnabled = YES;
[introLabel addGestureRecognizer:labelTapGestureRecognizer];
//创建一个返回富文本的方法
-(NSMutableAttributedString*)changeLabelWithText:(NSString*)needText
{
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:needText];
//range的参数,第一个是开始的位置,第二个是长度
//UIFont *font = [UIFont systemFontOfSize:15];
//[attrString addAttribute:NSFontAttributeName value:font range:NSMakeRange(4,4)];
[attrString addAttribute:NSForegroundColorAttributeName value:RGBA(32, 169, 242, 1) range:NSMakeRange(4,4)];
return attrString;
}