KMAdvertisementCollectionHeadView.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // KMAdvertisementCollectionHeadView.swift
  3. // KMAdvertisement
  4. //
  5. // Created by lizhe on 2022/11/28.
  6. //
  7. #if os(OSX)
  8. import AppKit
  9. #elseif os(iOS)
  10. import UIKit
  11. #endif
  12. class KMAdvertisementCollectionHeadView: NSView {
  13. lazy var titleTextField: NSTextField? = {
  14. for view in self.subviews {
  15. if view is NSTextField {
  16. return view as? NSTextField
  17. }
  18. }
  19. return nil
  20. }()
  21. var model: KMAdvertisementModel.Section! {
  22. didSet {
  23. self.reloadData()
  24. }
  25. }
  26. func reloadData() {
  27. if model?.sectionTitle?.language != nil {
  28. self.titleTextField?.stringValue = KMAdvertisementModelTransition.transitionLanguage(langeuage: (model?.sectionTitle?.language)!)
  29. }
  30. if model.sectionTitle?.color != nil {
  31. self.titleTextField?.textColor = KMAdvertisementModelTransition.transitionColor(color: (model.sectionTitle?.color)!, highlight: false)
  32. }
  33. }
  34. override func draw(_ dirtyRect: NSRect) {
  35. super.draw(dirtyRect)
  36. // Drawing code here.
  37. }
  38. }