// // KMGeneralButton.swift // PDF Reader Pro // // Created by lizhe on 2023/10/12. // import Cocoa @objcMembers class KMGeneralButton: NSButton { var color: NSColor = NSColor.red // 请替换为您需要的颜色 override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) let rect = self.bounds let coverRect = NSMakeRect(dirtyRect.size.width - 2.5, 0, 0, dirtyRect.size.height) color.setFill() let be = NSBezierPath(roundedRect: rect, xRadius: rect.size.width / 2, yRadius: rect.size.height / 2) be.fill() color.setFill() let coverPath = NSBezierPath(rect: coverRect) coverPath.fill() } }