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)
任何的意见都将会有帮助
我认为这个问题可以与这个问题合并Screenshotting on Iphone in swift only has a white background
这似乎是一样的
编辑:
我想我找到了解决方案.
首先阅读这篇文章:How Do I Take a Screen Shot of a UIView?
我创建了一个Extensions.swift文件,其中我使用该链接扩展了UIVIEw的方法.
之后,我只需将以下内容连接到我的精灵工具包按钮
let screenshot = self.vIEw?.pb_takeSnapshot()UIImageWritetoSavedPhotosAlbum(screenshot,nil)
Voilà,图像在相机胶卷中!
总结以上是内存溢出为你收集整理的如何以编程方式拍摄屏幕截图(Swift,SpriteKit)全部内容,希望文章能够帮你解决如何以编程方式拍摄屏幕截图(Swift,SpriteKit)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)