EmojiInputCell.swift 746 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // EmojiInputCell.swift
  3. // LoopKit
  4. //
  5. // Copyright © 2017 LoopKit Authors. All rights reserved.
  6. //
  7. import UIKit
  8. class EmojiInputCell: UICollectionViewCell, IdentifiableClass {
  9. @IBOutlet var label: UILabel!
  10. override var isSelected: Bool {
  11. didSet {
  12. updateSelectionState()
  13. }
  14. }
  15. override var isHighlighted: Bool {
  16. didSet {
  17. updateSelectionState()
  18. }
  19. }
  20. private func updateSelectionState() {
  21. let highlightColor: UIColor
  22. highlightColor = .tertiarySystemFill
  23. backgroundColor = isSelected || isHighlighted ? highlightColor : nil
  24. }
  25. override func awakeFromNib() {
  26. super.awakeFromNib()
  27. layer.cornerRadius = 8
  28. }
  29. }