Label color - dark mode support?

262
1
01-23-2020 12:11 PM
MichaelDavis3
Occasional Contributor III

Is there a mechanism available to set the label color for a feature class to SystemDefault or one of the other dark mode-aware system colors?

If not is there a way to update the label definition to switch colors when traitCollectionDidChange is fired?

I've wired up some of our apps to automatically switch to the dark vector map when users toggle on dark mode, but unfortunately it makes the labels unreadable.

0 Kudos
1 Reply
Nicholas-Furness
Esri Regular Contributor

We don't have a way to lean on UIKit system colors (one of the side-effects of having a cross-platform core to the Runtime).

While you should be able to manually modify the labels, we don't have an API for this yet. But if you're willing to tinker with some JSON you should be able to get this to work.

On an AGSFeatureLayer there is a labelDefinitions property. This is an array of AGSLabelDefinition objects.

You could call toJSON on each AGSLabelDefinition in that array, modify the appropriate symbol color and then create a new AGSLabelDefinition from the modified JSON using AGSLabelDefinition.fromJSON, and replace the definition in the labelDefinitions array.

It's messy but should work. We're working on fleshing out these APIs in future releases, but for now ask that you get the JSON and work with that.

Let me know if that helps.

Nick

0 Kudos