MKMapView にテキストを含む円オーバーレイを描画しようとしています。MKCircleView をサブクラス化し、そこに ( thisに基づいて) 以下を配置しましたが、テキストは表示されません。円は正しく表示されます。(最初の応答の解決策も試しましたが、同じ結果です)。
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
[super drawMapRect:mapRect zoomScale:zoomScale inContext:context];
NSString * t= @"XXXXX\nXXXX" ;
UIGraphicsPushContext(context);
CGContextSaveGState(context);
[[UIColor redColor] set];
CGRect overallCGRect = [self rectForMapRect:[self.overlay boundingMapRect]];
NSLog(@"MKC : %lf, %lf ----> %lf , %lf ", mapRect.origin.x ,mapRect.origin.y , overallCGRect.origin.x, overallCGRect.origin.y);
[t drawInRect:overallCGRect withFont:[UIFont fontWithName:@"Arial" size:10.0] lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter];
CGContextRestoreGState(context);
UIGraphicsPopContext();
}
デバッグすると、次のような値が得られます
MKC : 43253760.000000, 104071168.000000 ----> 1.776503 , 1.999245
MKC : 43253760.000000, 104071168.000000 ----> -1.562442 , -2.043090
彼らは正常ですか?何が欠けていますか?
ありがとう。