Re: NSAnimatablePropertyContainer
Re: NSAnimatablePropertyContainer
- Subject: Re: NSAnimatablePropertyContainer
- From: Troy Stephens <email@hidden>
- Date: Fri, 16 Nov 2007 09:42:33 -0800
Change your setImageAlpha:0.0 to message the view directly:
[myCustomView setImageAlpha:0.0];
That will set up the initial value, from which you'll then animate to
1.0.
The way the code is written now, [[myCustomView animator]
setImageAlpha:0.0] queues up an animation from the present value to
0.0 (which won't begin executing until control returns to the
runloop). Then [[myCustomView animator] setImageAlpha:1.0] schedules
another animation to 1.0 that supersedes the animation to 0.0. Almost
certainly the reason that changes to "imageToDisplay" after the first
fail to animate is that imageAlpha is already 1.0, so the animation to
1.0, the one that replaces the animation to 0.0, has nothing to do.
On Nov 15, 2007, at 7:22 PM, I. Savant wrote:
List:
I'm finally playing around with Core Animation. I have a view which
(for simplicity sake) has two properties:
NSImage * imageToDisplay (default nil)
CGFloat imageAlpha (default 0.0)
I have the +defaultAnimationForKey: working fine. It dutifully
returns a well-formed CABasicAnimation per the example in the
NSAnimatablePropertyContainer protocol reference documentation.
I want to do something like this:
- (void)someMethodWithSomeImage:(NSImage *)image
{
[[myCustomView animator] setImageAlpha:0.0];
[myCustomView setImageToDisplay:image];
[[myCustomView animator] setImageAlpha:1.0];
}
When imageToDisplay is first set, the new image fades in from the
default 0.0 beautifully. Subsequent sets fail to animate (they go
straight to the new image). I *assume* this is because the animation
is non-blocking and by the time the first interpolated alpha value
gets set (and drawn) the custom view's imageToDisplay is already
something else.
I spent quite some time tonight trying to figure out how to set the
'blocking mode' as NSAnimation allows ( [someNSAnimation
setAnimationBlockingMode:NSAnimationBlocking] ) but CAAnimation,
CABasicAnimation, etc. don't seem to allow this.
Am I missing something or is it not possible to have a blocking
animation in this way?
--
I.S.
_______________________________________________
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
_______________________________________________
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