Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animating setHidden: on NSView via Cocoa bindings

I'm currently putting the final touches on a project.

A lot (if not all) of the UI logic currently relies on Cocoa Bindings. Some of the user interface elements (labels, buttons, etc.) have their "Hidden" bindings defined. When certain events are triggered, these elements visibility is toggled.

I'm trying to animate the visibility change (by animating the opacity and maybe even the scale). This could easily be accomplished in a number of ways, either by setting the relevant layer properties, adding the animations to the layer, etc. However, since I'm trying to totally rely on the bindings behavior I "can't" really do this directly.

I tried an implementation using Layer actions, by defining actions for the keys kCAOnOrderIn and kCAOnOrderOut on the relevant elements, but it really didn't work, as the setHidden: is most likely being triggered on the NSView instead of the CALayer -- which makes sense.

So, my question is: how would you animate setHidden: on a NSView, when setHidden: is being invoked by the Cocoa Bindings.

Thank you.

like image 395
phluid Avatar asked Oct 13 '22 17:10

phluid


1 Answers

This will fade out an NSView...

[[someView animator] setAlphaValue:0.0f];
like image 75
AlBeebe Avatar answered Oct 18 '22 12:10

AlBeebe