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?
Hey!
I have list of my tags. Every tag has 2 states:
selected
anddeselected
. I'm tracking selection of my tags in separateNSMutableArray
. Of course when those 2 states have different colors (reversed). I noticed that I had sendsetNeedsLayout
message toAMTagView
object to redisplaytextColor
properly:My question is: Maybe it could be worth to override
setTextColor
method inAMTagView
?