KMWatermarkAdjectiveTopBarItemView.swift 968 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // KMWatermarkAdjectiveTopBarItemView.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/15.
  6. //
  7. import Cocoa
  8. class KMWatermarkAdjectiveTopBarItemLineView: NSView {
  9. }
  10. class KMWatermarkAdjectiveTopBarItemView: NSView {
  11. var button: NSButton!
  12. override init(frame frameRect: NSRect) {
  13. super.init(frame: frameRect)
  14. button = NSButton()
  15. button.isBordered = false
  16. self.addSubview(button)
  17. }
  18. required init?(coder: NSCoder) {
  19. super.init(coder: coder)
  20. }
  21. override func layout() {
  22. super.layout()
  23. button.frame = self.bounds
  24. }
  25. func isSelected(selected: Bool) {
  26. if (selected) {
  27. self.wantsLayer = true
  28. self.layer?.backgroundColor = NSColor(white: 0, alpha: 0.2).cgColor
  29. } else {
  30. self.wantsLayer = true
  31. self.layer?.backgroundColor = NSColor.clear.cgColor
  32. }
  33. }
  34. }