커스텀 이미지와 대체 이미지로 코코아 경사 버튼을 만들 때 나는 이상한 행동을하고 있습니다. 눌린 상태에서 버튼 배경은 흰색이됩니다. 버튼을 투명한 창 (HUD 창)의 하위보기로 추가하고 있습니다. 나는 내가 아는 모든 기술을 시도하고있다클릭하면 NSButton 흰색 배경
:
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에서 창 오버레이경사 버튼 :
잘못된 베벨 버튼 배경 :
이 NSWindow myWindow는 분명하지 않습니다. 버튼 컨테이너입니까? 이 경우 내용 rect는 NSRect rect로 정의한 것입니다. – loretoparisi
지금은 분명합니까? –
아주 좋습니다. – loretoparisi