KMButtonLayer.swift 916 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // KMButtonLayer.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/11/21.
  6. //
  7. import Cocoa
  8. enum KMNoteFilerButtonLayerType: Int {
  9. case none = 0
  10. case dot
  11. }
  12. class KMButtonLayer: CALayer {
  13. var layerType: KMNoteFilerButtonLayerType = .none {
  14. didSet {
  15. if (self.layerType == .dot) {
  16. self.backgroundColor = KMAppearance.Layout.l_1Color().cgColor
  17. self.cornerRadius = 6
  18. } else {
  19. self.backgroundColor = KMAppearance.Layout.l_1Color().cgColor
  20. self.cornerRadius = 6
  21. }
  22. }
  23. }
  24. override func draw(in ctx: CGContext) {
  25. if (self.layerType == .dot) {
  26. KMContextAddEllipseInRect(ctx, NSMakeRect(14, 2, 8, 8))
  27. KMContextSetRGBFillColor(ctx, 34/255.0, 122/255.0, 255/255.0, 1.0)
  28. KMContextDrawPath(ctx, .fill);
  29. } else {
  30. }
  31. }
  32. }