UIGraphicsBeginImageContextWithOptions(self.AgsMapView.bounds.size,false, 0.0)
self.view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
snapShot = UIGraphicsGetImageFromCurrentImageContext()
他是我的代码,从上面的代码得到空白图像(白色)
最佳答案
试试这个密码!!
let layer = self.AgsMapView.layer
let scale = UIScreen.mainScreen().scale
UIGraphicsBeginImageContextWithOptions(self.AgsMapView.frame.size, false, scale);
layer.renderInContext(UIGraphicsGetCurrentContext()!)
let snapShot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil)