浏览代码

ActionSheetCell: Fix cell colors when switching bewteen themes

(Fixes #519)
Carola Nitz 6 年之前
父节点
当前提交
290e9d0d05
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12 3
      Sources/ActionSheet/ActionSheetCell.swift

+ 12 - 3
Sources/ActionSheet/ActionSheetCell.swift

@@ -18,9 +18,7 @@ class ActionSheetCell: UICollectionViewCell {
 
     override var isSelected: Bool {
         didSet {
-            let colors = PresentationTheme.current.colors
-            name.textColor = isSelected ? colors.orangeUI : colors.cellTextColor
-            tintColor = isSelected ? colors.orangeUI : colors.cellDetailTextColor
+            updateColors()
             checkmark.isHidden = !isSelected
         }
     }
@@ -70,6 +68,17 @@ class ActionSheetCell: UICollectionViewCell {
         setupViews()
     }
 
+    private func updateColors() {
+        let colors = PresentationTheme.current.colors
+        name.textColor = isSelected ? colors.orangeUI : colors.cellTextColor
+        tintColor = isSelected ? colors.orangeUI : colors.cellDetailTextColor
+    }
+
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        updateColors()
+    }
+
     private func setupViews() {
         backgroundColor = PresentationTheme.current.colors.background