有人知道该怎么做这个问题:我的图像在自定义MKPolygonView翻转颠倒?iPhone MapKit:带图像的自定义MKPolygonView绘制倒过来
这个想法(这是工作正常)已经有一个类“SnowmapsOverlayView”,扩展“MKPolygonView”,显示图像。此图片在地图上的默认位置为&(用作Google Maps Web API中的GroundOverlay)。这一切工作正常,但图像倒过来显示。我tryed以下选项,但没有结果:
CGContextDrawImage draws image upside down when passed UIImage.CGImage
感谢任何帮助或建议!
我的代码:
#import <MapKit/MapKit.h>
@interface SnowmapsOverlayView : MKPolygonView
{
}
@end
-----------------
#import "SnowmapsOverlayView.h"
@implementation SnowmapsOverlayView
-(id)initWithPolygon:(MKPolygon *)polygon
{
self = [super initWithPolygon:polygon];
return self;
}
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
UIImage *image = [UIImage imageNamed:@"snowmap.png"];
//This should do the trick, but is doesn't.. maybe a problem with the "context"?
//CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
//CGContextTranslateCTM(context, 0, image.size.height);
//CGContextScaleCTM(context, 1.0, -1.0);
CGRect overallCGRect = [self rectForMapRect:self.overlay.boundingMapRect];
CGContextDrawImage(context, overallCGRect, image.CGImage);
}
-(BOOL)canDrawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale
{
return YES;
}
你刚帮我解决了一个大问题..谢谢! – 2011-05-27 10:54:19