Dark Mode - Mouse Events Reverting Layers?

Running 10.14 Beta 11, Xcode 10 GM.


I've been diligently updating my apps to support dynamic Dark/Light Mode, but I've run into a problem that has me a bit baffled. I've been following the instructions presented at WWDC to make sure all of my custom views and controls with custom layers get the appropriate color updates when a user switches between Light and Dark Mode. This all seems to be working quite well. However, on controls that have animations in response to mouse events (e.g., Mouse Over) - I seem to end up with the layers reverting back to their previous effective appearance upon mouseover.


The sequence will go like this:

1. Set the Appearance of macOS to Light Mode

2. Start my App

- everything looks appropriate - in light mode.

3. Switch the Apperanace of macOS to Dark Mode

- all of my custom controls/views switch their apperance and things look appropriate - in dark mode

4. Mouse over my custom controls

- my layers suddenly revert back to their light mode appearance even though they looked fine a second ago and I'm still in dark mode


It's like there is some sort of Core Animation layer caching going on that I'm not updating when switching to Dark Mode. I only seem to have this problem when deaing with mouse events. However, I didn't see anything about such a notion when watching the WWDC videos. Anyone have any idea?

Replies

Insertion of next line in custom view / control initial stage may resolve your problem.


self.wantsLayer = YES;

These controls already had this done in the initializers - no luck.