【问题标题】:repeating UIImage in mkmapviewoverlay在 mkmapviewoverlay 中重复 UIImage
【发布时间】:2011-05-02 21:20:43
【问题描述】:

我想将图像显示为 MKMapView 的叠加层。

图像已显示,但问题是它不适合 mkmapview 的可见矩形,它显示的是 4 张图像而不是 1 张。

我该如何解决。 图片截图

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {

UIGraphicsPushContext(context);

CGRect rect=[self rectForMapRect:mapRect];
NSLog(@"rect width:%f height:%f",rect.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();

}

即使我尝试调整图像大小但没有用..

【问题讨论】:

  • 请检查您添加的叠加图像的框架。请发布您的代码
  • 嗨..,我发布了代码..

标签: iphone uiimage mkmapview


【解决方案1】:

我解决了我的问题如下,

实际上,我在将区域设置为mapview之前将overlayview添加到mapview,

如果我在设置地图视图区域后添加叠加视图,它可以正常工作并显示单个图像。

[self.myMapView setRegion:aRegion animated:YES];

[self.myMapView addOverlay:customoverlay];

【讨论】:

    【解决方案2】:

    我不确定这是否会对您有所帮助,但值得尝试了解绘制叠加图像的想法

    MKOverlay View is blurred

    另一个链接:

    How to display an image on a MKOverlayView?

    【讨论】:

    • 嗨,我试过了,但我的叠加层仍然显示 4 张图片
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 2017-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多