Cocoa: change cursor when it's over an NSButton

前端 未结 5 778
一整个雨季
一整个雨季 2020-12-01 14:26

How can I change the cursor when it\'s over an NSButton?

5条回答
  •  Happy的楠姐
    2020-12-01 15:09

    If NSButton in macOS, swift 5:

    import Cocoa 
    class ViewController: NSViewController {
    
        @IBOutlet weak var titleBtn: NSButton!
            
         override func viewDidLoad() {
           titleBtn.addCursorRect(titleBtn.bounds, cursor: .pointingHand)
         }
    }
    

提交回复
热议问题