mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

PointAnnotations not switching between dark and light mode

Open ir-fuel opened this issue 3 years ago • 0 comments

Environment

  • Xcode version: 13.4.1
  • iOS version: 15.5
  • Devices affected: all
  • Maps SDK Version: 10.5.1

Observed behavior and steps to reproduce

Creating a PointAnnotation with an UIImage that has both dark and light mode assets does not switch when the device goes from light to dark mode.

        var firstPointAnnotation = PointAnnotation(coordinate: firstCoordinate)
        var lastPointAnnotation = PointAnnotation(coordinate: lastCoordinate)

        let startImage = UIImage(named: "startIcon")!.resizedTo(height: 30)
        firstPointAnnotation.image = .init(image: startImage, name: "startIcon")

        let endImage = UIImage(named: "endIcon")!.resizedTo(height: 30)
        lastPointAnnotation.image = .init(image: endImage, name: "endIcon")

This will show the icon on the map in the mode that the device was in the moment the map is first rendered. However when switching modes in the iPhone settings the annotation will stay light if it was first rendered in light mode, or dark if it was first rendered in dark mode.

The only solution is to remove the annotations and create them again.

Expected behavior

The annotation should show in dark mode when the device is in dark mode, and light when the device is in light mode

ir-fuel avatar Jul 05 '22 11:07 ir-fuel