在使用YYLabel的时候,最好使用YYLabel的是textTapAction手势处理全部文字点击手势,高亮实现highlightTapAction手势。
默认情况下,这两手势都会响应,那怎么去区分开这两个手势的响应呢?
详情如代码中处理
@weakify(self);self.contentLabel.textTapAction = ^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {@strongify(self);//获取点击部分的attributeTextNSAttributedString *att = [text attributedSubstringFromRange:range];//查找yy_attributes中是否存在高亮的YYTextHighlightAttributeNameYYTextHighlight *highlight = [att.yy_attributes valueForKey:YYTextHighlightAttributeName];if (highlight) {// 存在} else {[self contentTapEvent];}};
