Seb Jachec
Seb Jachec

Reputation: 3061

NSGradient fade/animation

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.

Upvotes: 0

Views: 324

Answers (1)

Seb Jachec
Seb Jachec

Reputation: 3061

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.

Upvotes: 2

Related Questions