ビューの画像を取得しようとしているので、NSImageView
.
NSView
SbitmapImageRepForCachingDisplayInRect:
方式を採用しています。
ただし、このメソッドは、ウィンドウの背景なしで、ビューの内容のみを返します。
画面に表示されているように、背景色などでビュー全体の画像を取得するにはどうすればよいですか?
現在のコード
- (NSImage *)imageOfView:(NSView *)view {
NSBitmapImageRep* rep = [view bitmapImageRepForCachingDisplayInRect:view.bounds];
[view cacheDisplayInRect:view.frame toBitmapImageRep:rep];
return [[NSImage alloc] initWithCGImage:[rep CGImage] size:view.bounds.size];
}