【问题标题】:MKMapView showsUserLocation default is gray dot, not blue oneMKMapView 显示UserLocation 默认是灰点,不是蓝点
【发布时间】:2014-07-17 10:01:56
【问题描述】:

我在视图控制器中添加了一个 MKMapView,将 showsUserLocation 设置为 YES:

MKMapView *mapView =[[MKMapView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/2)];
mapView.delegate=self;
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.showsUserLocation = YES;
[self.view addSubview:mapView];

并实现了协议:

- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation{
    MyAnnotation * myannotation=(MyAnnotation * )annotation;
    if(annotation != aMapView.userLocation)
    {
        // create a customized MKAnnotationView and return it. blabla
        return annView;
    }
    else
    {
        [aMapView.userLocation setTitle:NSLocalizedString(@"i_am_here",nil)];
    }
    return nil;
}

它在一个白色圆圈内显示一个灰点。当用户位置更新时,灰色部分正在动画。我期望的是一个蓝点,就像 Apple 的 iOS 地图应用程序中的那个一样,我不想为 userLocation 自定义视图(动画......)

有没有什么简单的设置可以将点的颜色从灰色变成蓝色?

我在 iPhone 5c, 7.1.1 上测试它; Xcode 5.1.1

该代码在 iOS 5 和 6 之前应该可以正常运行。

【问题讨论】:

标签: ios iphone objective-c


【解决方案1】:

看看你的 mapview tintcolor。

例如self.mapview.tintColor = [UIColor grayColor];点颜色为灰色,设置为蓝色,返回蓝色。

【讨论】:

  • 谢谢!它确实是 tintColor 的东西!
【解决方案2】:

你可以使用:

mapView.tintColor = .red

【讨论】:

    猜你喜欢
    • 2011-01-31
    • 2011-08-30
    • 2013-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多