usesAdaptiveColorMappingForDarkAppearance

The apple documentation:


https://developer.apple.com/documentation/appkit/nstextview/3237223-usesadaptivecolormappingfordarka?language=objc


goes into a lot of detail. Does anyone have any further insights into this and what it does?

  • Works for me, but in dark mode, also prints an NSTextView white-on-black. Any idea how to fix this?

Add a Comment

Replies

I guess I will answer my own question--I do talk to myself a lot anyway.


It seems that usesAdaptiveColorMappingForDarkAppearance returns no as the default. Setting it to yes has, so far, allowed me to eliminate a lot of code for updating colors when switching from light to dark. The textViews do this automatically now and even if there is colored text, it still works. Colored text remains colored in its original color. Black and white text, even if in a grayscale range, adapts to the light or dark modes. Very nice. So, my suggestion is to set this to YES for textViews and see what happens. As I said, it allowed me to clean up a lot of code that monitored appearance mode, made changes, etc.

I wish this was available for UITextView as well and quite frankly I have no idea why it's not. However, it seems you had to do this on the Mac side before usesAdaptiveColorMappingForDarkAppearance was introduced. Do you have any hints as to what needs to be done to accomplish this? Thanks!