KMPageEditBaseItemView.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // KMPageEditBaseItemView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/1/11.
  6. //
  7. import Cocoa
  8. // 页面编辑 [视图] [基类]
  9. class KMPageEditBaseItemView: NSView {
  10. lazy var titleLabel: NSTextField = {
  11. let label = NSTextField(labelWithString: "")
  12. return label
  13. }()
  14. var contentInset = NSEdgeInsetsMake(8, 16, 0, 0) {
  15. didSet {
  16. self.layoutSubtreeIfNeeded()
  17. }
  18. }
  19. var itemClick: KMCommonClickBlock?
  20. override var isFlipped: Bool {
  21. return true
  22. }
  23. override init(frame frameRect: NSRect) {
  24. super.init(frame: frameRect)
  25. self.initSubviews()
  26. }
  27. required init?(coder: NSCoder) {
  28. super.init(coder: coder)
  29. self.initSubviews()
  30. }
  31. func initSubviews() {
  32. self.addSubview(self.titleLabel)
  33. }
  34. override func layout() {
  35. super.layout()
  36. self.titleLabel.frame = NSMakeRect(self.contentInset.left, self.contentInset.top, NSWidth(self.bounds)-self.contentInset.left-self.contentInset.right, 22)
  37. }
  38. }