KMTabStripView.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // KMTabStripView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2022/12/12.
  6. //
  7. import Cocoa
  8. class KMTabStripView: CTTabStripView {
  9. override func awakeFromNib() {
  10. super.awakeFromNib()
  11. if self.addTabButton != nil {
  12. self.addTabButton.wantsLayer = true
  13. self.addTabButton.layer?.cornerRadius = 4
  14. // self.addTabButton.toolTip = String(format: "%@(%@O)", KMLocalizedString("Open File"),kCommandString)
  15. let view = KMCoverButton()
  16. self.addTabButton.addSubview(view)
  17. view.km_add_inset_constraint()
  18. view.wantsLayer = true
  19. view.title = ""
  20. view.isEnabled = false
  21. view.layer?.backgroundColor = .clear
  22. view.isBordered = false
  23. view.coverAction = { [weak self] button, action in
  24. if (action == .enter) {
  25. var color = NSColor(red: 237/255.0, green: 238/255.0, blue: 240/255.0, alpha: 1)
  26. if KMAppearance.isDarkMode() {
  27. color = NSColor(white: 0.35, alpha: 1)
  28. }
  29. self?.addTabButton.layer?.backgroundColor = color.cgColor
  30. } else if (action == .exit) {
  31. self?.addTabButton.layer?.backgroundColor = .clear
  32. }
  33. }
  34. }
  35. }
  36. }