我需要更改MKPointAnnotation
对象的颜色,但我编写的方法似乎只生成红色引脚。该方法工作正常,但是当我调用该函数并传递给定常量之一的参数时,地图上出现的所有引脚都是红色的(默认值)。有什么想法吗?代码如下。
-(MKAnnotationView*) returnPointView: (CLLocationCoordinate2D) location andTitle: (NSString*) title andColor: (int) color{
/*Method that acts as a point-generating machine. Takes the parameters of the location, the title, and the color of the
pin, and it returns a view that holds the pin with those specified details*/
MKPointAnnotation *resultPin = [[MKPointAnnotation alloc] init];
MKPinAnnotationView *result = [[MKPinAnnotationView alloc] initWithAnnotation:resultPin reuseIdentifier:Nil];
[resultPin setCoordinate:location];
resultPin.title = title;
result.pinColor = color;
return result;
}
//Function that calls above method
for(Party *party in allParties){
if(!party.alreadyAdded){
CLLocationCoordinate2D location = [party getPartylocation];
NSString *partyTitle = [party getPartyName];
MKAnnotationView *partyPin = [self returnPointView:location andTitle:partyTitle andColor:MKPinAnnotationColorGreen];
[self.map addAnnotation:partyPin.annotation];
NSLog(@"Adding Successful!");
party.alreadyAdded = YES;
}
}