如何拍摄AGSMapView for ios的快照?

时间:2016-06-06 10:35:42

标签: ios swift

      UIGraphicsBeginImageContextWithOptions(self.AgsMapView.bounds.size,false, 0.0)
        self.view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
        snapShot = UIGraphicsGetImageFromCurrentImageContext()

他是我的代码,从上面的代码获取空白图像(白色)

1 个答案:

答案 0 :(得分:0)

试试这段代码!!

    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)