From 87b256525fdf458eb71d9fab1b1fea2eb51cefc5 Mon Sep 17 00:00:00 2001 From: ibireme Date: Thu, 7 Jan 2016 23:48:07 +0800 Subject: [PATCH] remove discontinuous attributes when called `setText:` --- YYKit/Text/YYLabel.m | 1 + 1 file changed, 1 insertion(+) diff --git a/YYKit/Text/YYLabel.m b/YYKit/Text/YYLabel.m index 7c4d2b29..f7035d69 100644 --- a/YYKit/Text/YYLabel.m +++ b/YYKit/Text/YYLabel.m @@ -529,6 +529,7 @@ - (void)setText:(NSString *)text { _text = text.copy; BOOL needAddAttributes = _innerText.length == 0 && text.length > 0; [_innerText replaceCharactersInRange:NSMakeRange(0, _innerText.length) withString:text ? text : @""]; + [_innerText removeDiscontinuousAttributesInRange:NSMakeRange(0, _innerText.length)]; if (needAddAttributes) { _innerText.font = _font ? _font : [self _defaultFont]; _innerText.color = _textColor;