質問

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?

役に立ちましたか?

解決

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

[btn setShowsBorderOnlyWhileMouseInside:YES];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top