本文介绍了Mapkit引脚颜色不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做以下操作,并且总是得到绿色引脚:
I'm doing the following and always get green pins:
pin.pinColor = MKPinAnnotationColorRed;
[self.mapView addAnnotation:pin];
[pin release];
pin的类型为NSObject。所有引脚显示为绿色。
pin is of type "NSObject ". All pins come out as green. Should I be doing it differently?
推荐答案
确保你的pin类实现了协议,我相信得到非标准的针脚颜色,你会必须实施方法。
Make sure your pin class implements the MKAnnotation protocol and I believe to get a non-standard pin color, you'll have to implement the viewForAnnotation method.
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"redpin"];
newAnnotation.pinColor = MKPinAnnotationColorRed;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
这篇关于Mapkit引脚颜色不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!