repeating UIImage in mkmapviewoverlay
I want to display an image as an overlay to MKMapView.
The image is displayed, but the problem is it does not fit the visible rect of the mkmapview, it is showing 4 images instead of one.
How do I fix it. screenshot of the image
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
UIGraphicsPushContext(context);
CGRect rect=[self rectForMapRect:mapRect];
NSLog(@"rect width:%f height:%f",r开发者_运维问答ect.size.width,rect.size.height);
[scaledImage drawInRect:[self rectForMapRect:mapRect] blendMode:kCGBlendModeNormal alpha:1.0];
//[scaledImage drawInRect:CGRectMake(0, 0, 320, 367) blendMode:kCGBlendModeOverlay alpha:.07];
UIGraphicsPopContext();
}
even I tried resize of image but no use..
I solved my issue as follows,
Actually,I added overlayview to mapview before setting the region to mapview,
If i added overlay view after region of the mapview is set, it works fine and showed single image.
[self.myMapView setRegion:aRegion animated:YES];
[self.myMapView addOverlay:customoverlay];
I am not sure if this will help you but its worth a try to get an idea on drawing an overlay image
MKOverlay View is blurred
Another link:
How to display an image on a MKOverlayView?
精彩评论