-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UILabel backgroundColor does not work well #2
Comments
I find another easier way to reproduce the bug. Just don't add the code in step 3, touch any one of the cell and use two-finger change theme. Then you can find we changed the cell's selectedBackgroundView instead of the backgroundView. |
Hi Cubernet! Thanks for making me aware of this problem! However, it isn't an issue with Gagat per se, but rather with how
(The same thing seems to happen when highlighting a cell as well) One way to work around this is to keep track of the current style in the cell, and then always restore the label's background color when the cell is unhighlighted or deselected: // ArchiveTableViewCell.swift
private var currentStyle: Style?
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
if let currentStyle = currentStyle, !highlighted {
titleLabel.backgroundColor = currentStyle.titleBackgroundColor
}
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if let currentStyle = currentStyle, !selected {
titleLabel.backgroundColor = currentStyle.titleBackgroundColor
}
}
func apply(style: Style) {
currentStyle = style
// ...
} Hopefully this helps you. Let me know if it doesn't and I'll reopen the issue! 🙂 |
It works and thank you very much! |
Hi,
When I tested the demo project on my iPhone6s Plus(10.3.3), I found a bug. You can reproduce the bug in the following steps.
The text was updated successfully, but these errors were encountered: