カスタム MKPolygonView の私の画像が上下逆になっていますか?
アイデア(これはすでに正常に機能しています)は、画像を表示する「MKPolygonView」を拡張するクラス「SnowmapsOverlayView」を持っています。この画像には、マップ上のデフォルトの位置とサイズがあります (Google マップ Web API で GroundOverlay として機能します)。これはすべて正常に機能していますが、画像が上下逆に表示されます。次のオプションを試しましたが、結果はありません。
CGContextDrawImage は、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;
}