Make NSToolbar Icon for NSToolbar - cocoa

I'd like to make an icon for my NSToolbar that has the same system stylings applied to it as the template icons in IB. How do you do this? I can't get the toolbar to apply system stylings like it says it will in the HIG.
Thanks!

In Mac OS X v10.5 or later, images whose name ends in the word "Template" are automatically marked as template images. NSImage Class Reference
NSImage *image = [NSImage imageNamed:#"MyImageTemplate"];
This also works for Interface Builder.
More information: http://www.proppe.org/blog/2007/12/01/nsimage-templates/

If you mean for a monochromatic icon, make sure you set it as a template image. That's what tells the system to render it with the inner gray or blue gradient.

The toolbar doesn't do that automatically. You have to create the graphics yourself. The Lion-style icons are usually mid-gray with a subtle inner shadow and a 1px whitish drop shadow. Here's an example done in Photoshop:
And here's all the layer styling done to it:
The specific numbers and colors may vary depending on the icon's shape and size.
On a side note, the HIG was saying that icons may change depending on the control. For example, when you disable a button, its icon will be displayed semi-transparently.

Related

How to set automatically font size change of UIButton regardless of the orientation of the device?

I want to have my buttons changes font size, when user change orientation.
Is it possible to do it in storyboard?
Thanks.
Unless you are targeting an old iOS version, don't use the word "orientation". They are called "size classes" now. You should work with them instead of orientations.
In the storyboard's property inspector, there is a little "+" next to the font property:
If you click that, you can add a new value for font when it is changed to a specific size class:
Here I made the font size bigger if it is horizontally regular:
IMO, you shouldn't change the font size depending on the size class and/or orientation. There might be something wrong with your design...

Change Background Color of Full Screen Application- Xcode

Good Afternoon helpful people!
I'm building a mac app that displays images. The app will be in fullscreen mode 100% of the time it is running.
My issue is that the images I am displaying do not fill the entire screen, therefore, showing a grayish background. Is there anyway to change this background color to Black? Or maybe it's the NSImageView that needs the background color changed?
I do not see anywhere in my Xcode Attributes Inspector to change color.
Thanks!
The solution to this is, in my case, to add an NSBox in storyboard and set its constraints so that it ALWAYS fills the view. Once you have done this, go to the Atrributes Inspector and change its Fill Color to your desired color.
The important part here is the constraints. Set Top, Bottom, Left, and Right space to 0. Hope that makes sense, i'm new to constraints.

Toggle NSToolbarItem between Black and Blue

I'd like to make an NSToolbarItem with a custom image which toggles between Black and Blue, like the icons at the top right of Xcode 5's main window.
Peter Hosey suggested in this answer that it was as simple as setting the image to be a template, but I haven't found that to be the case. I set it to a template image, and that causes it properly render the dark gray gradient, but it doesn't render in blue when toggled.
I uploaded a very simple example of what I've done, here. If someone could tell me how to change it to light up the NSToolbarItem in blue, as Xcode does, then I'd very much appreciate it.
You mostly have everything you need in place, with the exception of providing an NSButton object using the style NSTexturedRoundedBezelStyle, with which you’ve associated your image.
↳ modified example project here
⌘ OS X Human Interface Guidelines | Window-Frame Controls

OSX NSStatusBar statusbar icon dimensions?

I couldn't find a document or hint which dimensions a statusbar or menubar icon in OSX should have. I found out that such an icon has 18x18 pixel for normal displays, but how to do that for retina displays? Is it 36x36 and are the usually naming coventions ...#2 working in this case?
The official apple docs covers informations of all other icon sizes, but nothing about a status bar icon.
From the docs:
When you create an icon to put inside a toolbar control in PDF format,
OS X will automatically scale your icon for high-resolution display.
You do not need to provide a high-resolution version.
there is no #2X version.
For freestanding icons in a toolbar, create inviting images that are
easy to identify. Because freestanding toolbar icons do not need to
fit within a toolbar control, you have a little more room to express
them. As you design a freestanding icon for your toolbar, follow these
guidelines:
Use a straight-on perspective. Make the outline sharp and clear. Use
anti-aliasing. Use color judiciously to add meaning. Create icons for
standard- and high-resolution displays. You need to supply two
resources: 32x32 and 32x32#2x. See Table 5-1 for the corresponding
canvas sizes. Use the PNG format.
For reference

Transparent rounded window but with opaque controls

I am trying to make a HUD with a transparent rounded window with opaque controls as is commonly seen in apps such as Xcode popups, the native volume control, etc.
I'm using the technique detailed here: How to implement HUD-style window like Address Book's "Show in Large Type"
but this renders controls in the view transparent. I've tried setAlphaValue:1.0 on the controls but that has no effect. Searches for other solutions point to Matt Gemmell's RoundedFloatingPanel component. I can't open the project in Xcode 4, but looking at the code as far as I can tell the only difference seems to be in Matt's code he sets the alpha of the window to 1.0 and uses a transparent fill for the NSRect in the view. I tried this but still end up with transparent controls.
So unsurprisingly, Matt Gemmell's code works just fine and I had made a mistake. I forgot that I was also messing with the alpha of the window elsewhere in my code in order to make it fade out on close.
To to sum it up for others running into this issue, if you set the alpha on the NSWindow the controls in that window will also be transparent. Instead set the alpha on the NSBezierPath fill color in the NSView. Just like Matt Gemmell's code does. :)

Resources