EmojiInputCell.swift 870 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. if #available(iOSApplicationExtension 13.0, *) {
  23. highlightColor = .tertiarySystemFill
  24. } else {
  25. highlightColor = .white
  26. }
  27. backgroundColor = isSelected || isHighlighted ? highlightColor : nil
  28. }
  29. override func awakeFromNib() {
  30. super.awakeFromNib()
  31. layer.cornerRadius = 8
  32. }
  33. }