カスタム イメージと代替イメージを使用して Cocoa ベベル ボタンを作成すると、奇妙な動作が発生します。押された状態では、ボタンの背景が白くなります。透明なウィンドウ (HUD ウィンドウ) のサブビューとしてボタンを追加しています。
私が知っているすべてのテクニックを試しています:
NSButton *closeButton = [[NSButton alloc] initWithFrame:NSMakeRect(0.0, 0.0, 30.0, 30.0)];
[closeButton setFrameOrigin:NSMakePoint(0.0, 0.0)];
[closeButton setImagePosition:NSImageOnly];
[closeButton setAction:@selector(closeWindowAction:)];
[closeButton setBordered:NO];
[closeButton setTransparent:NO];
[closeButton setImage:[NSImage imageNamed:@"icon-tclose-off"]];
[closeButton setAlternateImage:[NSImage imageNamed:@"icon-tclose-on"]];
[closeButton setBezelStyle:NSShadowlessSquareBezelStyle];
[closeButton setButtonType:NSMomentaryLightButton];
//[[closeButton cell] setBackgroundColor:[NSColor clearColor]];
[[closeButton cell] setHighlightsBy:NSChangeBackgroundCellMask|NSCellLightsByContents];
//[[closeButton cell] setHighlightsBy:NSContentsCellMask];
//[[closeButton cell] setShowsStateBy:0|NSContentsCellMask];
私も試しました
[closeButton setButtonType:NSMomentaryChangeButton];
[[closeButton cell] setHighlightsBy:NSContentsCellMask];
結果なし。
添付のスクリーンショットで間違った動作を確認できます。
HUD ウィンドウをオーバーレイするベベル ボタン:
間違ったベベル ボタンの背景: