KMNewUserGuideDisplayView.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // KMNewUserGuideDisplayView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/12/21.
  6. //
  7. import Cocoa
  8. class KMNewUserGuideDisplayView: NSView {
  9. private lazy var iv_: NSImageView = {
  10. let view = NSImageView()
  11. return view
  12. }()
  13. var imageView: NSImageView {
  14. get {
  15. return iv_
  16. }
  17. }
  18. var contentInset: NSEdgeInsets = .init(top: 0, left: 0, bottom: 0, right: 0) {
  19. didSet {
  20. leftConst_?.constant = contentInset.left
  21. rightConst_?.constant = -contentInset.right
  22. topConst_?.constant = contentInset.top
  23. bottomConst_?.constant = -contentInset.bottom
  24. }
  25. }
  26. private var leftConst_: NSLayoutConstraint?
  27. private var topConst_: NSLayoutConstraint?
  28. private var rightConst_: NSLayoutConstraint?
  29. private var bottomConst_: NSLayoutConstraint?
  30. convenience init() {
  31. self.init(frame: .init(x: 0, y: 0, width: 200, height: 30))
  32. initSubViews()
  33. }
  34. override func awakeFromNib() {
  35. super.awakeFromNib()
  36. initSubViews()
  37. }
  38. func initSubViews() {
  39. addSubview(imageView)
  40. leftConst_ = imageView.km_add_leading_constraint_r()
  41. topConst_ = imageView.km_add_top_constraint_r()
  42. rightConst_ = imageView.km_add_trailing_constraint_r()
  43. bottomConst_ = imageView.km_add_bottom_constraint_r()
  44. }
  45. }