How to resize MKAnnotationView on iOS6?

你说的曾经没有我的故事 提交于 2019-11-30 10:28:03

Apple suggests resizing the .image property of an annotation view. In my case shown below, I looked at the UIImage that was set in the viewforAnnotation and re-scaled it to the zoom level in a UIPinchGestureRecognizer

   UIImage *orangeImage = [UIImage imageNamed:@"Orange210.PNG"];
    CGRect resizeRect;
    //rescale image based on zoom level
    resizeRect.size.height = orangeImage.size.height * scale;
    resizeRect.size.width = orangeImage.size.width  * scale ;
    NSLog(@"height =  %f, width = %f, zoomLevel = %f", resizeRect.size.height, resizeRect.size.width,zoomLevel );
    resizeRect.origin = (CGPoint){0,0};
    UIGraphicsBeginImageContext(resizeRect.size);
    [orangeImage drawInRect:resizeRect];
    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    pinView.image = resizedImage;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!