开发者

repeating UIImage in mkmapviewoverlay

开发者 https://www.devze.com 2023-02-15 12:47 出处:网络
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.

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

repeating UIImage in mkmapviewoverlay

- (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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号