更改引脚devise
有没有可能把MKAnnotation pin改成我自己devise的PNG?
重写这个,并成为一个MKMapViewDelegate委托来实现覆盖该方法。
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation;
创build一个注释,
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"];
自定义图像完成
是的,在viewForAnnotation委托callback中,你可以提供你喜欢的任何视图。
对于自定义注释图像,请设置图像属性。
UIImage *annImage = [UIImage imageNamed:@"AnnotationIcon.png"]; annView.image = annImage;
请注意MKPinAnnotationView animateDrop属性在自定义图像上不起作用。 有一种方法可以复制该animation。 请参阅如何animationMKAnnotationView放置?