Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change NSToolbar icons for different toolbar size

Tags:

cocoa

NSToolbar can have two sizes controlled by the user using "Use Small Size" menu item. Regular toolbar size requires 32x32 icon sizes for each item while small size uses 24x24. I don't want icons to scale by default since i have a pair of icons for each toolbar size. Instead i want icons to automatically switch to the other size when user changes toolbar size.

Now IB only has a single image field for each toolbar item. Is there a way to automatically change icon size or do i have to subclass NSToolbar and react to size changes manually and fix the icons for each item?

like image 533
Inso Reiges Avatar asked Jan 17 '12 06:01

Inso Reiges


Video Answer


1 Answers

From the Apple Guide for toolbars:

You should provide image representations specific to the default, regular and small size modes in a single image that supports multiple image representations such as icns or tiff. The appropriate image representation is automatically displayed for the toolbar's current sizeMode. If an appropriate representation is not available, the toolbar scales the a representation to the appropriate size for the current mode, at a cost in performance and appearance.

like image 149
Sam Avatar answered Sep 26 '22 12:09

Sam