开发者

In Cocoa, how could you create an NSImage from a view? (Very similar to Top Sites in Safari 4.)

开发者 https://www.devze.com 2022-12-11 10:50 出处:网络
Actually, almost exactly the same thing. A matrix o开发者_如何学JAVAf small views that would expand out when you click on them. I don\'t know if it makes more sense to take a snapshot of the view as a

Actually, almost exactly the same thing. A matrix o开发者_如何学JAVAf small views that would expand out when you click on them. I don't know if it makes more sense to take a snapshot of the view as an image and work with that, or if there is a way to keep the views "live". Thoughts on either approach are welcome!


[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];


NSBitmapImageRep *bitmap = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
[view cacheDisplayInRect:[view bounds] toBitmapImageRep:bitmap];

Then use that to draw elsewhere, perhaps by placing it into an NSImage. Or alternatively, use the PDF-based technique described by @Chuck.

0

精彩评论

暂无评论...
验证码 换一张
取 消