KMHeaderFooterAdjectiveInfoBaseView.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // KMHeaderFooterAdjectiveInfoBaseView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/27.
  6. //
  7. import Cocoa
  8. typealias KMHeaderFooterAdjectiveInfoItemClick = (_ index: Int,_ value: Any) -> ()
  9. class KMHeaderFooterAdjectiveInfoBaseView: NSView {
  10. var titleLabel = NSTextField(labelWithString: "")
  11. var contentInset = NSEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
  12. private var myModel: KMHeaderFooterAdjectiveModel!
  13. var model: KMHeaderFooterAdjectiveModel {
  14. get {
  15. return myModel
  16. }
  17. set {
  18. myModel = newValue
  19. }
  20. }
  21. var itemClick: KMHeaderFooterAdjectiveInfoItemClick!
  22. override init(frame frameRect: NSRect) {
  23. super.init(frame: frameRect)
  24. initSubviews()
  25. }
  26. required init?(coder: NSCoder) {
  27. super.init(coder: coder)
  28. initSubviews()
  29. }
  30. override var isFlipped: Bool {
  31. return true
  32. }
  33. func initSubviews() {
  34. self.addSubview(self.titleLabel)
  35. }
  36. override func layout() {
  37. super.layout()
  38. self.titleLabel.frame = NSMakeRect(self.contentInset.left, 0, NSWidth(self.bounds)-self.contentInset.left-self.contentInset.right, 20)
  39. }
  40. }