这个问题困扰了好长时间,参考了http://stackoverflow.com/questions/19571357/ios-sprite-kit-screengrab 这篇问题解决了。
我的spritekit截屏代码:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0.0);
[self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES];
self.sharingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
本文介绍了一种在iOS上使用SpriteKit进行屏幕截图的方法。通过UIGraphicsBeginImageContextWithOptions等API,可以有效地捕获当前视图的状态并将其转换为图片。此方法适用于那些希望在游戏中实现分享功能的开发者。
141

被折叠的 条评论
为什么被折叠?



