有谁知道如何“快照”一个完整的SKView或SKScene成一个NSImage?
我们已经能够使用API从节点及其所有子节点textureFromNode创建一个。SKTexture但到目前为止,我们还想不出一种方法来将图像数据提取到NSImage. 我们正在构建一个混合Cocoa/SpriteKit应用程序,我们需要在其中提取场景的小缩略图。
同样,这在 iOS 上似乎是可能的(获得 a UIImage)使用drawViewHierarchyInRect:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是如何做到这一点Cocoa呢NSImage?帮助。