Use the Text on Shape tool From the available shapes, select the shape on which you want to add text. Drag the cursor on the image to create the shape. To add text to the image, hover the mouse over the path until the cursor icon changes to depict text mode. Click the point to add text.
I'm trying to draw some circle overlays containing text on MKMapView. I have subclassed the MKCircleView, in which I put the following (based on this), but the text does not appear. The circles show up correctly. (Also tried the first response's solution, same result).
-(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();
}
When debugging, I get values like these
MKC : 43253760.000000, 104071168.000000 ----> 1.776503 , 1.999245
MKC : 43253760.000000, 104071168.000000 ----> -1.562442 , -2.043090
Are they normal ? What am I missing ?
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With