NSSplitView
에있는 NSScrollView
안에 사는 사용자 지정 NSView가 있습니다. 내가 operation
의 모든 다른 유형을 시도했지만 이미지가 여전히 같은 NSSplitView
의 나머지 절반의 위에 그립니다다른 뷰 위에 NSScrollView의 그림이 그려져 있습니다.
- (void)drawRect:(NSRect)dirtyRect {
NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
[ctx saveGraphicsState];
// Rounded Rect
NSRect rect = [self bounds];
NSRect pathRect = NSMakeRect(rect.origin.x + 3, rect.origin.y + 6, rect.size.width - 6, rect.size.height - 6);
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:pathRect cornerRadius:kDefaultCornerRadius];
// Shadow
[NSShadow setShadowWithColor:[NSColor colorWithCalibratedWhite:0 alpha:0.66]
blurRadius:4.0
offset:NSMakeSize(0, -3)];
[[NSColor colorWithCalibratedWhite:0.196 alpha:1.0] set];
[path fill];
[NSShadow clearShadow];
// Background Gradient
NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[UAColor darkBlackColor] endingColor:[UAColor lightBlackColor]];
[gradient drawInBezierPath:path angle:90.0];
[gradient release];
// Image
[path setClip];
NSRect imageRect = NSMakeRect(pathRect.origin.x, pathRect.origin.y, pathRect.size.height * kLargeImageRatio, pathRect.size.height);
[self.image drawInRect:imageRect
fromRect:NSZeroRect
operation:NSCompositeSourceAtop
fraction:1.0];
[ctx restoreGraphicsState];
[super drawRect:dirtyRect];
}
:
사용자 정의보기는 다음 그리기 코드를 사용 ... NSScrollView
에서 그림을 그리는 대신 나는 이것이 dirtyRect
대신에 모든 것을 그리는 것과 관련이 있다고 생각하지만, 나는 그림 코드를 편집하여 어떻게 그 부분을 그릴 수 있는지 모른다. dirtyRect
에있다. 어떻게 그 위에 그리지 못하도록 할 수 있습니까? 아니면이 NSImage에 대해 더러운 사각형 만 그리시겠습니까?