NSView change type of property animation
I have an NSButton
that I'd like to animate when I call [button setHidden: NO];
However, I don't want the default fade animation, I'd like a slide-from-left animation instead.
I'm sure it's not that complicated, but I'm struggling to find the right location in the docs. 开发者_如何学运维Any suggestions?
You should change the frame via the animator proxy.
NSRect aFrameMoreToTheLeft = …;
[[button animator] setFrame:aFrameMoreToTheLeft];
Looks like the correct answer to add a custom animation to the layer, and then just set the property, instead of using the default animator for the property:
CATransition *animation = [CATransition animation];
[animation setDuration: 0.2];
[animation setType: kCATransitionMoveIn];
[animation setSubtype: kCATransitionFromRight];
[animation setTimingFunction: [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]];
[[button layer] addAnimation: animation forKey: @"slidebutton"];
[button setHidden: NO];
Still not 100% clear what the difference is on Mac OS X between kCATransitionFade
and kCATransitionReveal
.
精彩评论