MKMapView: user location pin color change to gray automatically

1.2k views Asked by At

This is strange, I have a ViewController which adds a MKMapView as a subview. There are some steps in the application which when executed causes the user location pin to change its color from blue to gray.

I have investigated in the following

  1. there is no place where tintColor is changed in code base
  2. used KVO to observe tint Color
  3. analyzed that in "viewWillAppear"(till last line) tintColor is "UIDeviceRGBColorSpace 0 0.478431 1 1" while in "viewDidAppear" tintColor changes to "UIDeviceWhiteColorSpace 0.392275 0.8"

Please elaborate if change in Color Space.

 CGFloat mapviewY = self.searchView.frame.origin.y + self.searchView.frame.size.height + 1;
CGFloat mapviewHeight = self.view.frame.size.height - mapviewY;
_klMapView = [[KMapMapView alloc] initWithFrame:CGRectMake(kScreenOrigin,
                                                           mapviewY,
                                                           SCREEN_WIDTH,
                                                           mapviewHeight)];
_klMapView.mapViewDelegate = self;
[self.view addSubview:_klMapView];

Thanks Ankit

2

There are 2 answers

2
Sahil Kapoor On

Check out if you are using mapView(mapView: _, viewForAnnotation: _) and format it this way.

 func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
            if annotation.isKindOfClass(MKUserLocation) {
                return nil
            }
            // rest of your code
    }
0
Ankit Sachan On

Ok so got the answer actually tintAdjustmentMode was getting changed. Fixed it by

mapView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;