Question

Simply put: is it possible to fade between two NSGradient "fills" on a single NSView? Eg. draw one gradient and fade to drawing the next one.

Was it helpful?

Solution

I ended up subclassing NSView; getting an NSImage from it; creating a temporary NSView drawing the new gradient which is the same size as the original and getting an image from that; drawing the starting image in an NSImageView, which is a subview of the original NSView; then using a CATransition to fade to another NSImageView with the new image. Finally, I'd get my NSView drawing the new gradient and remove the NSImageView, in case any more custom drawing was to be done.

Published my code on GitHub.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top