와 이상한 문제를, -setClip 사용. 정확히 다음과 같습니다.Redrawed 삽입 NSShadow이 질문의 대답과 관련이 내가 가지고있는 방법
- (void)drawRect:(NSRect)rect
{
// Create and fill the shown path
NSBezierPath *path = [NSBezierPath
bezierPathWithRoundedRect:[self bounds]
xRadius:4.0f
yRadius:4.0f];
[[NSColor colorWithCalibratedWhite:0.8f alpha:0.2f] set];
[path fill];
// Save the graphics state for shadow
[NSGraphicsContext saveGraphicsState];
// Set the shown path as the clip
[path setClip];
// Create and stroke the shadow
NSShadow * shadow = [[[NSShadow alloc] init] autorelease];
[shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0f alpha:0.8f]];
[shadow setShadowBlurRadius:2.0];
[shadow set];
[path stroke];
// Restore the graphics state
[NSGraphicsContext restoreGraphicsState];
if (highlight && [[self window] firstResponder] == self) {
NSSetFocusRingStyle(NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect:[self bounds]] fill];
}
}
여러 줄로 된 레이블 (형제 또는 내 사용자 지정보기의 자식)을 추가하면 문제가 발생합니다.
내 프로그램 창이 포커스를 잃어 버렸고 돌아 왔을 때 내 안의 그림자/뇌졸중이 어두워졌습니다. 그림자가 겹쳐 보이는 것 같습니다. 내 윈도우에이 사용자 정의보기 만 있으면 잘됩니다.
I 라인
[path setClip];
그림자가 더 이상 중첩되지 않습니다 언급,하지만 난 (NSBox 이상의 유사) 둥근 모서리의 원하는 효과를 얻을 수없는 경우.
여러 줄 레이블 대신 누름 단추를 사용하면 어떤 일이 벌어 지는지 알아 보았습니다. 창 포커스를 잃거나 잃는 데 아무런 문제가 없지만 단추를 클릭하면 그림자가 겹쳐집니다.
나는 문제가 여기보다 더 유사하다 발견, 대신 자바의 코코아 :
도와감사합니다!
setClip과 동일한 효과 (또는 비슷한)와 다시 그리기가 없습니다. 나는 그것을 고려할 것이다. 감사! –