KMAdvertisementCollectionHeadView.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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: KMAdvertisementItem! {
  22. didSet {
  23. self.reloadData()
  24. }
  25. }
  26. func reloadData() {
  27. self.isHidden = true
  28. if model?.name != nil {
  29. self.titleTextField?.stringValue = KMAdvertisementModelTransition.transitionLanguage(langeuage: (model?.name)!)
  30. }
  31. self.isHidden = false
  32. self.titleTextField?.textColor = KMAppearance.Layout.h1Color()
  33. // if model.sectionTitle?.color != nil {
  34. // self.titleTextField?.textColor = KMAdvertisementModelTransition.transitionColor(color: (model.sectionTitle?.color)!, highlight: false)
  35. // }
  36. }
  37. override func draw(_ dirtyRect: NSRect) {
  38. super.draw(dirtyRect)
  39. // Drawing code here.
  40. }
  41. }