Skip to content

Instantly share code, notes, and snippets.

@Abhishek9634
Created April 2, 2019 05:43
Show Gist options
  • Save Abhishek9634/9bc0742000c1ffc1ef0a2f33f0ec24bb to your computer and use it in GitHub Desktop.
Save Abhishek9634/9bc0742000c1ffc1ef0a2f33f0ec24bb to your computer and use it in GitHub Desktop.
import UIKit
class DropDownTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var imgView: UIImageView!
var item: Any? {
didSet {
self.configure(self.item)
}
}
override func awakeFromNib() {
super.awakeFromNib()
}
func configure(_ item: Any?) {
guard let model = item as? DropDownCellModel else { return }
self.titleLabel.text = model.item.value
self.updateUI(model.isSelected)
}
private func updateUI(_ flag: Bool) {
self.titleLabel.textColor = flag ? .blue : .black
self.imgView.isHidden = !flag
self.titleLabel.textColor = flag ? UIColor(hexString: "1098BC") : .black
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment