Skip to content

Commit

Permalink
override setTextColor to adapt attribution stages properly accordin…
Browse files Browse the repository at this point in the history
…g to new text color.
  • Loading branch information
TomKnig committed Nov 11, 2014
1 parent 0475dd0 commit 28ba19c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Classes/TOMSMorphingLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ - (void)numberOfAttributionStagesShouldChange
}
}

- (void)setTextColor:(UIColor *)textColor
{
[super setTextColor:textColor];

@synchronized(self) {
for (NSMutableDictionary *attributionStage in self.attributionStages) {
if ([attributionStage[NSForegroundColorAttributeName] isKindOfClass:[UIColor class]]) {
UIColor *attributionStageColor = attributionStage[NSForegroundColorAttributeName];
CGFloat attributionStageAlpha = CGColorGetAlpha(attributionStageColor.CGColor);
attributionStage[NSForegroundColorAttributeName] = [self textColorWithAlpha:attributionStageAlpha];
}
}
}
}

- (void)setTextWithoutMorphing:(NSString *)text
{
BOOL wasMorphingEnabled = self.isMorphingEnabled;
Expand Down Expand Up @@ -316,7 +331,6 @@ - (void)applyAttributionStage:(NSInteger)stage toString:(NSString *)aString
attributionIndex = MIN(self.numberOfAttributionStages - 1, MAX(0, attributionIndex));

NSMutableDictionary *attributionStage = self.attributionStages[attributionIndex];
attributionStage[NSForegroundColorAttributeName] = self.textColor;
CGFloat kernFactor = [attributionStage[kTOMSKernFactorAttributeName] floatValue];
NSString *character = [aString substringWithRange:range];
CGSize characterSize = CGSizeZero;
Expand Down

0 comments on commit 28ba19c

Please sign in to comment.