Enhancement: Changing textColor on the fly.
PatrykKaczmarek opened this issue · 2 comments
PatrykKaczmarek commented
Hey!
I have list of my tags. Every tag has 2 states: selected
and deselected
. I'm tracking selection of my tags in separate NSMutableArray
. Of course when those 2 states have different colors (reversed). I noticed that I had send setNeedsLayout
message to AMTagView
object to redisplay textColor
properly:
self.selectedTags = [NSMutableArray array];
[self.tagListView addTags:@[@"my tag", @"some tag"]];
[self.tagListView setTapHandler:^(AMTagView *view) {
BOOL contains = [self.selectedTags containsObject:[view tagText]];
contains ? [self.selectedTags removeObject:[view tagText]] : [self.selectedTags addObject:[view tagText]]; // is there better way to track selected tags?
if (contains) {
[view setInnerTagColor:[UIColor whiteColor]];
[view setTextColor:[UIColor redColor]];
} else {
[view setInnerTagColor:[UIColor redColor]];
[view setTextColor:[UIColor whiteColor]];
}
[view setNeedsLayout]; // <-- here have to do it manually
}];
My question is: Maybe it could be worth to override setTextColor
method in AMTagView
?
- (void)setTextColor:(UIColor *)textColor {
_textColor = textColor;
[self setNeedsLayout];
}
andreamazz commented
Good call 👍
You'll find the fix in version 0.8.1
PatrykKaczmarek commented
Thanks!