iphoneuser-interfacestylesuitoolbaruitoolbaritem

How can I style an MKUserTrackingBarButtonItem?


I'm adding the items programatically, but MKUserTrackingBarButtonItem doesn't seem to offer any way to style it to fit in with a BlackTranslucent UIToolBar...

enter image description here


Solution

  • MKUserTrackingBarButtonItem is a subclass of UIBarButtonItem which has a tintColor property. You can use this to make your button black.

    MKUserTrackingBarButtonItem *userTrackingBarButtonItem = 
            [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
    
    [self.navigationController.toolbar setBarStyle:UIBarStyleBlack];
    [userTrackingBarButtonItem setTintColor:[UIColor blackColor]];
    

    If you do set it to black like this, the user will never know when it's activated, as the blue color is never shown.

    black button