0

I am trying to set the tint color of my MKAnnotationView image so that it behaves in dark mode-

pinView = mapView.dequeueReusableAnnotationView(withIdentifier: WeatherMapViewController.mapViewWeatherID)
if pinView == nil {
     pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: WeatherMapViewController.mapViewWeatherID)
     pinView?.image = UIImage(systemName: "cloud.sun.rain")?.withTintColor(.label, renderingMode: .alwaysOriginal)

But the SF symbol image is always black no matter the tint color. Can anyone suggest a way to lighten the icon when in dark mode?

David
  • 305
  • 2
  • 10
  • This is actually kind of a [duplicate](https://stackoverflow.com/questions/22694750/set-tintcolor-to-mkannotationview-image), but all of the answers there create a new image that is rendered with a colour; but this doesn't work for dynamic colours, so the image will be rendered correctly for the initial traits but not re-rendered if the light/dark trait changes. You could hook into the trait change notification and trigger a reset of your annotations or you can create your own subclass of `MKAnnotationView` that has a `UIImageView` and use that. – Paulw11 Feb 09 '21 at 10:02
  • I think `.alwaysOriginal` means 'ignore the tintColor'. – Gerd Castan Feb 14 '21 at 14:49

0 Answers0