// // HyperLinkButton.swift // PDF Reader Pro // // Created by Niehaoyu on 2024/1/10. // import Cocoa @objcMembers class HyperLinkButton: KMButton { override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // Drawing code here. } override class func awakeFromNib() { super.awakeFromNib() } override var title: String { didSet { self.attributedTitle = self.hyperlink()! } } func hyperlink() -> NSAttributedString? { var str = NSMutableAttributedString.init(attributedString: self.attributedTitle) str.addAttributes([NSAttributedString.Key.underlineStyle : true], range: NSRange(location: 0, length: self.title.count)) return str; } }