获得MKOverlayRenderer的框架是可能的吗?

时间:2015-03-21 20:35:59

标签: ios mkmapview mkoverlay

实际上,我正在尝试从我的应用程序中删除已弃用的代码(将目标部署从iOS6修改为iOS7),我正在寻找替代方案。这是旧代码:

- (void) mapTapped:(UITapGestureRecognizer *)sender
{
    CMELog(@"mapTapped");
    if (sender.state != UIGestureRecognizerStateEnded)
        return;

    CGPoint mapTouchPoint = [sender locationInView:mainMapView];
    CLLocationCoordinate2D mapTouchCoord = [mainMapView convertPoint:mapTouchPoint toCoordinateFromView:mainMapView];
    MKMapPoint touchMapPoint = MKMapPointForCoordinate(mapTouchCoord);
    CMELog(@"touchMapPoint: x:%f, y:%f", touchMapPoint.x, touchMapPoint.y);

    // this is where things can get inefficient if you have loads of overlayViews that aren't even visible!
    for (id<MKOverlay> overlay in self.mainMapView.overlays)
    {
        MKOverlayView *overlayView = [self.mainMapView viewForOverlay:overlay];
        CGSize overlayViewSize = overlayView.frame.size;
        CGPoint touchPoint = [sender locationInView:overlayView];
        // check to see if the point is within the overlay bounding box first
        if (touchPoint.x > 0 && touchPoint.x < overlayViewSize.width && touchPoint.y > 0 && touchPoint.y < overlayViewSize.height)
        {
        }
    }
}

我用以下内容替换了循环中的第一行:

MKOverlayRenderer *rendererOverlay = [self.mainMapView rendererForOverlay:overlay];

但我找不到如何获取渲染叠加的帧。好吗?

0 个答案:

没有答案