Google Maps IOS SDK 1.2需要地图视图快照



在1.1中,gmsscreen类提供了一种基本的方法来获取整个屏幕的快照到UIImage中。在1.2中,这个类没有了,在发行说明中,它是这样说的:

  • 在GMSMapView层上调用renderInContext:现在可以正确渲染;这允许快照和UI效果

不幸的是,我没有发现这种情况。典型的renderInContext:不工作在Open GL绘图,但我想我会采取一个镜头(它没有工作)。有人成功地获得(首选)视图或屏幕快照吗?

我可以截图。下面是我使用的代码:

UIGraphicsBeginImageContext(mapView_.frame.size);
[mapView_.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我没有在创建地图后直接调用它,因为它可能需要一些帧来渲染地图。

最新更新