tôi thêm chú thích vào bản đồ của tôi theo cách này:Thay đổi pin màu MKMapView
MyAnnotation *annotationPoint2 = [[MyAnnotation alloc] init];
annotationPoint2.coordinate = anyLocation;
annotationPoint2.title = [NSString stringWithFormat:@"%@", obj];
annotationPoint2.subtitle = @""; //or set to nil
annotationPoint2.keyValue = [NSString stringWithFormat:@"%@", key];
[mapPins addAnnotation:annotationPoint2];
Các chân đều đỏ, và tôi muốn tất cả chúng màu xanh lá cây. Làm thế nào tôi có thể thay đổi màu sắc? Tôi đã thử những điều sau đây, nhưng nó vẫn mang lại một dấu đỏ:
annotationPoint2.pinColor = MKPinAnnotationColorGreen;
mã này hoạt động, nhưng ngay cả vị trí người sử dụng hiện tại trở nên xanh, ngay cả khi tôi muốn nó màu xanh với các vòng tròn quanh nó. Làm thế nào tôi có thể làm điều đó? – Alessandro
nếu ([[chú thích tiêu đề] isEqualToString: @ "Vị trí hiện tại"]) { annView.pinColor = MKPinAnnotationColorGreen; } else {annView.pinColor = MKPinAnnotationColorRed;} – casillas
@Alessandro Bạn cần trả về nil khi chú thích == mapView.userLocation để hiển thị chấm màu xanh cho vị trí của người dùng và vòng tròn xung quanh nó – amitshinik