Search code examples
macoscocoansimageappkitnsbutton

My NSButton with icon has no icon


I have an NSButton in a nib that is set to an icon, and only an icon:

Screenshot of Xcode with the button selected, showing its image name set to NSQuickLookTemplate

When I run the app, the icon, despite being one of the images provided by AppKit, is missing:

Screenshot of the button in my app at run time, showing no image

What's going on here? Why isn't my button's icon showing up?


Solution

  • Okay. In my little sample app I just created, I was able to get the icon to appear (took a bit of doing, though). Summed up, you need to change the button type to "Bevel" and increase the height if necessary.

    Apparently "Push"-style NSButton types are too narrow to display the icon comfortably.