Prechádzať zdrojové kódy

ActionSheetCell: Icon: Observe image change to change hidden state

(closes #535)
Soomin Lee 6 rokov pred
rodič
commit
8ebda18e06
1 zmenil súbory, kde vykonal 20 pridanie a 2 odobranie
  1. 20 2
      Sources/ActionSheet/ActionSheetCell.swift

+ 20 - 2
Sources/ActionSheet/ActionSheetCell.swift

@@ -9,6 +9,24 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
+class ActionSheetCellImageView: UIImageView {
+    override var image: UIImage? {
+        didSet {
+            super.image = image
+            isHidden = false
+        }
+    }
+
+    override init(image: UIImage? = nil) {
+        super.init(image: image)
+        isHidden = true
+    }
+
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+}
+
 @objc(VLCActionSheetCell)
 class ActionSheetCell: UICollectionViewCell {
 
@@ -23,8 +41,8 @@ class ActionSheetCell: UICollectionViewCell {
         }
     }
 
-    let icon: UIImageView = {
-        let icon = UIImageView()
+    let icon: ActionSheetCellImageView = {
+        let icon = ActionSheetCellImageView()
         icon.translatesAutoresizingMaskIntoConstraints = false
         icon.contentMode = .scaleAspectFit
         return icon