【发布时间】:2020-07-09 03:30:14
【问题描述】:
现在我用这段代码捕获了:
CGRect bounds = self.scene.view.bounds;
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, [UIScreen mainScreen].scale);
[self.view drawViewHierarchyInRect:bounds afterScreenUpdates:YES];
UIImage* screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
这捕捉了整个场景。它工作得很好,但我想要的只是捕获一个放在场景中的具有透明背景的单个 SKNode。有没有办法做到这一点?
编辑:我试过了
self.scene.view.allowsTransparency = YES;
self.scene.backgroundColor = [UIColor clearColor];
self.scene.view.backgroundColor = [UIColor clearColor];
但也没有用。嗯。
【问题讨论】:
-
[SKView textureFromNode:node]->SKTexture-> 通过CGImage方法的底层图像 ->[UIImage imageWithCGImage:]- 这能解决你的问题吗?
标签: objective-c sprite-kit uiimage skspritenode