문제

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