Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an NSButton resize its image (Cocoa OSX)

I could not find a way in the documentation to tell an NSButton to resize its image to fill up the whole button. Is there a way to do this programatically?

like image 225
Mike2012 Avatar asked Dec 18 '22 04:12

Mike2012


1 Answers

The closest you'll get is -setImageScaling: ... look up the constants to see how the image will be scaled within the button cell, given its bordered state and bezel type.

If you're looking to replace the standard button entirely with your image (ie, the button cell doesn't draw itself at all - your image serves as the entire visual representation), turn off the border (-setBordered:).

All of these options can be configured in IB as well. A tip: in IB, hover the mouse over any setting in the inspector panel - most if not all give you a hint that shows what method controls the behavior affected by the setting's control.

like image 83
Joshua Nozzi Avatar answered Feb 16 '23 07:02

Joshua Nozzi