KMGeneralButton.swift 691 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // KMGeneralButton.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/10/12.
  6. //
  7. import Cocoa
  8. @objcMembers class KMGeneralButton: NSButton {
  9. var color: NSColor = NSColor.red // 请替换为您需要的颜色
  10. override func draw(_ dirtyRect: NSRect) {
  11. super.draw(dirtyRect)
  12. let rect = self.bounds
  13. let coverRect = NSMakeRect(dirtyRect.size.width - 2.5, 0, 0, dirtyRect.size.height)
  14. color.setFill()
  15. let be = NSBezierPath(roundedRect: rect, xRadius: rect.size.width / 2, yRadius: rect.size.height / 2)
  16. be.fill()
  17. color.setFill()
  18. let coverPath = NSBezierPath(rect: coverRect)
  19. coverPath.fill()
  20. }
  21. }