Re: autolayout-based animation on NSView
Re: autolayout-based animation on NSView
- Subject: Re: autolayout-based animation on NSView
- From: Roland King <email@hidden>
- Date: Thu, 14 Aug 2014 10:25:46 +0800
>
> It should work to do:
>
> [view layoutSubtreeIfNeeded];
> [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
> context.duration = 0.25; // you can leave this out if the default is acceptable
> context.allowsImplicitAnimation = YES;
> [view updateConstraintsAndVariousViewPropertiesForState:state];
> [view layoutSubtreeIfNeeded];
> } completionHandler:nil];
>
> This does require layer-backed views. It may be that you can leave out setting allowsImplicitAnimation if you use the view's animator for the second -layoutSubtreeIfNeeded, but I'm not sure. Supposedly, the animator turns on implicit animation, but I don't know if that's only when setting animatable properties.
Thanks - that works perfectly, even animates the ‘hidden’ property smoothly which I wasn’t getting with the animator proxy. I’ve yanked out most of the proxies from the update method, don’t need them and it makes the code scruffy.
Now I know what I am looking for (NSAnimationContext runAnimationGroup..) I did find an example in the docs, however it’s wrong and uses ‘[ NSView layoutIfNeeded ]’ for the OSX example instead of layoutSubtreeIfNeeded .. you can guess which method I was googling on :(
I’ll add ‘turn on layer-backed views’ to my OSX checklist, it seems like they may act more like the world I’m used to. Pleased I learned UIKit first or I wouldn’t even know what questions to ask, although even UIKit is slowly crufting up.
One animation to go and it’s shipping time !
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden