【发布时间】:2015-02-26 22:42:13
【问题描述】:
我尝试了任何建议,但输出是白色的空白屏幕截图。这使我假设我没有在视图中添加任何内容。这是我如何将图形添加到我的视图中。 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)
任何建议都会有所帮助
【问题讨论】:
-
addChild 方法是 SpriteKit 框架自带的。我不确定它将它们添加到什么。但我用它来使精灵可见。但是,当我使用 screenshot 方法时,它会返回一个白色的空白屏幕截图。
-
您必须在某个 SKNode 上调用 addChild。使用您发布的代码,不清楚您要将它们添加到哪个视图或节点(如果有)
-
标记我是为了什么?我为什么丢了两分?这太荒谬了,你们应该感到羞耻。
标签: swift sprite-kit uigraphicscontext skview