您好,我嘗試在MKPolygonView中繪製文本。我做了一個MKPolygonView的子類,並將其添加到我的MKMapView。多邊形正確顯示,但我看不到文本。誰能幫我?在MKPolygonView中繪製簡單的文本
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{
[super drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context];
CGRect overallCGRect = [self rectForMapRect:self.overlay.boundingMapRect];
UIFont* font = [UIFont fontWithName:@"ArialRoundedMTBold" size:20.0f];
NSString * t= @"Test";
[[UIColor redColor] set];
[t drawInRect:overallCGRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
}