// // KMAdvertisementCollectionHeadView.swift // KMAdvertisement // // Created by lizhe on 2022/11/28. // #if os(OSX) import AppKit #elseif os(iOS) import UIKit #endif class KMAdvertisementCollectionHeadView: NSView { lazy var titleTextField: NSTextField? = { for view in self.subviews { if view is NSTextField { return view as? NSTextField } } return nil }() var model: KMAdvertisementModel.Section! { didSet { self.reloadData() } } func reloadData() { if model?.sectionTitle?.language != nil { self.titleTextField?.stringValue = KMAdvertisementModelTransition.transitionLanguage(langeuage: (model?.sectionTitle?.language)!) } if model.sectionTitle?.color != nil { self.titleTextField?.textColor = KMAdvertisementModelTransition.transitionColor(color: (model.sectionTitle?.color)!, highlight: false) } } override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // Drawing code here. } }