Simple mouseover effect on NSButton

后端 未结 7 702
Happy的楠姐
Happy的楠姐 2021-02-04 01:51

I am creating a custom NSButtonCell for a custom rendering.

Now, I want to have different aspect depending if the mouse is over the button or not. How can

7条回答
  •  天涯浪人
    2021-02-04 02:11

    For those who prefer subclassing, you can also make your own NSButton and assigning the NSTrackingArea in it.

    Here is a really simple and elegant way to do it, thanks to Joey Zhou : https://github.com/Swift-Kit/JZHoverNSButton

    It is written in Swift 2 but XCode will automatically translate it in Swift 3 - 4 without any issue.

    Hope it can help someone

提交回复
热议问题