Skip to content

Commit

Permalink
Fix for foreground highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
hsusmita committed Aug 21, 2015
1 parent 33df2ed commit 49910bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ResponsiveLabel/ResponsiveLabel/Source/ResponsiveLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
Custom NSTextAttributeName which takes value of type PatternTapHandler.
It specifies the action to be performed when a range of text with that attribute is tapped.
*/
static NSString *RLTapResponderAttributeName = @"TapResponder";
static NSString *RLHighlightedForegroundColorAttributeName = @"HighlightedForegroundColor";
static NSString *RLHighlightedBackgroundColorAttributeName = @"HighlightedBackgroundColor";
extern NSString *RLTapResponderAttributeName;
extern NSString *RLHighlightedForegroundColorAttributeName;
extern NSString *RLHighlightedBackgroundColorAttributeName;

/**
Type for responder block to be specfied with RLTapResponderAttributeName
Expand Down
12 changes: 10 additions & 2 deletions ResponsiveLabel/ResponsiveLabel/Source/ResponsiveLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
static NSString *kRegexStringForUserHandle = @"(?<!\\w)@([\\w\\_]+)?";
static NSString *kRegexFormatForSearchWord = @"(%@)";

NSString *RLTapResponderAttributeName = @"TapResponder";
NSString *RLHighlightedForegroundColorAttributeName = @"HighlightedForegroundColor";
NSString *RLHighlightedBackgroundColorAttributeName = @"HighlightedBackgroundColor";


@interface ResponsiveLabel ()

@property (nonatomic, retain) NSLayoutManager *layoutManager;
Expand Down Expand Up @@ -262,7 +267,7 @@ - (void)removeTokenIfPresent {
[finalString appendAttributedString:hiddenString];

[self.textStorage setAttributedString:finalString];

//configure truncated pattern range
[self addAttributeForTruncatedRange];
}
Expand Down Expand Up @@ -569,6 +574,9 @@ - (void)removeHighlightingForIndex:(NSInteger)index {
[self.textStorage addAttribute:NSForegroundColorAttributeName
value:foregroundcolor
range:patternRange];
}else {
[self.textStorage removeAttribute:NSForegroundColorAttributeName
range:patternRange];
}
}
[self redrawTextForRange:patternRange];
Expand Down Expand Up @@ -676,7 +684,7 @@ - (void)initialTextConfiguration {
currentText = [[NSAttributedString alloc]initWithString:self.text
attributes:[self attributesFromProperties]];
}
[self updateTextStorage:currentText];
[self updateTextStorage:currentText];
}

/** This method extects the attributes from the properties of the label
Expand Down

0 comments on commit 49910bc

Please sign in to comment.