如何改变mapview iphone的颜色 [英] how to change color of pin for mapview iphone

查看:123
本文介绍了如何改变mapview iphone的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyAnnotation *ann1 = [[MyAnnotation alloc] init];

  ann1.coordinate =region.center;


  [mapView addAnnotation:ann1];

现在它的紫色我想要红色

right now its purple i want red

推荐答案

实现MKMapViewDelegate协议回调,并将实现类设置为地图视图委托

Implement MKMapViewDelegate protocol callback and set the implementing class as the map view delegate

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

    MKPinAnnotationView *newAnnotationPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"simpleAnnotation"] autorelease];
    newAnnotationPin.pinColor = MKPinAnnotationColorRed; // Or Red/Green
    return newAnnotation;

}

这篇关于如何改变mapview iphone的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆