Permalink
Browse files

[attributedlabel] Added custom attribute to count runCount correctly.

  • Loading branch information...
1 parent d02e83f commit 08dbf919404f151d0ee3ef65617c984d35459d63 @inamiy inamiy committed Aug 31, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/attributedlabel/src/NIAttributedLabel.m
@@ -1007,6 +1007,13 @@ - (void)_longPressTimerDidFire:(NSTimer *)timer {
- (void)_applyLinkStyleWithResults:(NSArray *)results toAttributedString:(NSMutableAttributedString *)attributedString {
for (NSTextCheckingResult* result in results) {
[attributedString setTextColor:self.linkColor range:result.range];
+
+ // Adding custom attribute is required to count runCount correctly,
+ // or runCount will be 1 (highlighting whole sentence)
+ // when self.textColor is equal to self.linkColor, and
+ // none of the below attribute-adding methods are getting called.
+ [attributedString addAttribute:@"LINK" value:[NSNumber numberWithBool:YES] range:result.range];
+
if (self.linksHaveUnderlines) {
[attributedString setUnderlineStyle:kCTUnderlineStyleSingle
modifier:kCTUnderlinePatternSolid

0 comments on commit 08dbf91

Please sign in to comment.