zekunyan / TTGTagCollectionView

Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time. It is highly customizable that most features of the text tag can be configured. 标签流显示控件,同时支持文字或自定义View
http://tutuge.me
MIT License
1.89k stars 260 forks source link

selectedContent text color is reset to black #116

Open 70m3n opened 3 years ago

70m3n commented 3 years ago

I set different background colors and text colors for normal content/style and selected content/style. Background colors always display correct, but the text color is reset when scrolling a tableView with a TTGTextTagCollectionView for each cell. So when the cell re-renders in cellForRowAt, the text color is almost always black. I set it to be white on selected tags.

zekunyan commented 3 years ago

@70m3n Can you provide some Demo code ? Thank you.

70m3n commented 3 years ago

It's hard to provide any demo code, because the app I'm working on has some fairly complex UI. That may also be the source of my problem. I did however make a sample app, with only one view controller with a table view, listing tags in several sections, thus rendering n number of TTGTextTagCollectionViews. That worked fine.

After som debugging in the app I'm working on I found that the text color in TTGTextTagStringContent wasn't reset back to the normal color I set (dark gray). It was reset back to black, which I'm not sure where comes from.

I'm not sure what causes the problem, if it is my code or the code in the package, or even a combination. Life cycle events. Race conditions. I'm out of options.

Thanks for your time, though.

I attached an image showing the problem in action.

Simulator Screen Shot - iPhone 12 mini - 2021-09-09 at 13 55 12

Ahmed-Masoud commented 3 years ago

I had the same issue I didn't notice that you can set content and selectedContent separately for a tag leaving this here for anyone in the future let tag = TTGTextTag.init() tag.content = content tag.selectedContent = selectedContent