Advanced Dark Mode WWDC session questions

o Is there some missing lines of code in the BubbleView code (27:06)? Like the call to [super layout]; and adding the materialView as a subview? Maybe this is not needed in Swift.


o The session explains that a NSBox can be used to get the tinted content color by settings the fill color to controlBackgroundColor.


There's a little problem with this solution from what I've seen. In Mojave, in Light mode, the controlBackgroundColor is white, in 10.10.5 for instance, the controlBackgroundColor is transparent.


So is it implicitly suggested that one should actually dynamically change the fill color through code depending on the AppKitVersionNumber?


o Is it possible for a 3rd party developer to create a custom NSColorSpace? The idea would be to support colorNamed: on version of Mac OS X earlier than 10.13.

Replies

Regarding your first point, from the AppKit Release Notes for macOS 10.12:


"When overriding [NSView layout], AppKit no longer requires calling [super layout]. In particular, the view.needsLayout bit is now cleared automatically outside of the [view layout] call. This allows you to completely override [view layout] and block all of the default layout behavior if so desired. Also note that the bit is cleared before [view layout] is called, which means that if you dirty layout during your [view layout] override (either via calling [view setNeedsLayout:YES] directly or by modifying constraints), it will schedule a second layout pass."

Interesting. I guess the layout documentation has not been updated appropriately.


Ref.: https://developer.apple.com/documentation/appkit/nsview/1526146-layout

Very likely - I believe that the Release Notes are correct and that the documentation is outdated. I filed 42358945.