Question

I just created some basic NSRecessedBezelStyle NSButton programmatically, the codes are listed below:

NSButton *btn = [[NSButton alloc] initWithFrame:NSMakeRect(80 + 110 * i, 11, 100, 19)];
[btn setTitle:@"Normal"];
[btn setButtonType:NSPushOnPushOffButton];
[btn setBezelStyle:NSRecessedBezelStyle];

But the result is like this:

picture

As you can see, the first and second button are created programmatically and the third and fourth buttons are made in the IB.

The buttons are looking good when they are in ON state, but not the same with OFF state.

The third one made with IB has no background color displayed (which is what I wanted), but the first one that I created in code has a background color with it. How can I solve this?

Was it helpful?

Solution

It looks like you'll need to add one additional line during the creation of the button:

[btn setShowsBorderOnlyWhileMouseInside:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top