Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create a custom themed NSButton?

Tags:

cocoa

How do you create a custom themed NSButton? I don't mean in a small way like changing the background color or changing from rounded edges to square edges. I want to replace the entire look and feel of the button. Is that even possible to do in Cocoa? Obviously I would have to subclass the NSButton class and go from there. Any help would be much appreciated.

like image 243
John Scipione Avatar asked Oct 28 '09 10:10

John Scipione


1 Answers

Actually, you need to subclass NSButtonCell. You should read Apple's documentation on this to gain a better understanding of how they interact. You probably will still want to subclass NSButton so that it will use your NSButtonCell subclass, too.

For a button, most of the work is done in drawBezelWithFrame:inView:. If you want to alter the way the text or image is drawn, you would override drawTitle:withFrame:inView: and drawImage:withFrame:inView:.

like image 90
Alex Avatar answered Sep 21 '22 21:09

Alex