在手势代理方中,判断YYLabel富文本中是否有高亮对象
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[YYLabel class]]){
YYLabel *label = (YYLabel *)touch.view;
NSAttributedString *attributedString = label.attributedText;
NSUInteger index = [label.textLayout textRangeAtPoint:[touch locationInView:label]].start.offset;
// 判断当前文本上是否有点击事件
YYTextHighlight *hl = [attributedString yy_attribute:YYTextHighlightAttributeName atIndex:index];
// 判断是否有高亮对象
return hl ? NO : YES;
}
}