本文介绍了改变引脚设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将MKAnnotation引脚更改为我自己设计的png?

Is it possible to change the MKAnnotation pin to a png of my own design?

推荐答案

覆盖此并成为MKMapViewDelegate的委托以实现覆盖方法。

override this and be a delegate of MKMapViewDelegate to implement override the method.

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation;

创建注释,

MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];// get a dequeued view for the annotation like a tableview

if (annotationView == nil)
    {
        annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease]; 
    }
    annotationView.annotation = annotation;
    annotationView.canShowCallout = YES; // show the grey popup with location etc
    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    ///[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
    annotationView.rightCalloutAccessoryView = rightButton;

    annoationView.image = [UIImage imageNamed:@"random.png"];

自定义图像已完成

这篇关于改变引脚设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 09:10