我尝试了建议的所有方法,但输出是一个白色的、空白的截图。这让我认为我没有在视图中添加任何内容。下面是我如何向我的视图添加图形的方式。addChild方法是由SpriteKit提供的,它接受SKSpriteNodes:
addChild(background)
addChild(rate)
addChild(scoreLabel)
addChild(share)
addChild(playAgain)
addChild(highScoreLabel)
addChild(scoreBackground)
addChild(highScoreBackground)
这是获取截图的方法:
UIGraphicsBeginImageContext(self.view!.bounds.size)
self.view!.layer.renderInContext(UIGraphicsGetCurrentContext())
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil)
有什么建议都可以提出来,谢谢。