自定义标注泡泡iOS

use*_*143 4 iphone mkmapview mkannotationview ios

我正在使用mapview功能开发应用程序.我想在mapview上显示自定义图钉图像,点击该图片和标题打开的自定义标注气泡.点击该标注气泡视图,我想做一些功能.怎么做到这一点?任何帮助将不胜感激

aks*_*h1t 7

前往CocoaControls进行自定义控件.我打赌你会发现一些对你的要求有用的东西.

以下是CocoaControls的一些搜索结果:


自定义图像

关于SO的问题已经在这里这里以及更多内容中回答.我敢说你会在他们中找到答案.基本上,代码是

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    if([annotation isKindOfClass:[MKUserLocation class]])
    return nil;

    NSString *annotationIdentifier = @"CustomViewAnnotation";
    MKAnnotationView* annotationView = [mapview dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
    if(!annotationView)
    {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
                                                  reuseIdentifier:annotationIdentifier]];
    }
    annotationView.image = [UIImage imageNamed:@"map_location_pin.png"];
    annotationView.canShowCallout= YES;

    return annotationView;
}
Run Code Online (Sandbox Code Playgroud)