Re: How to use CAMediaTiming's beginTime?
Re: How to use CAMediaTiming's beginTime?
- Subject: Re: How to use CAMediaTiming's beginTime?
- From: Bill Dudney <email@hidden>
- Date: Sat, 9 Feb 2008 05:09:02 -0700
Hi Joachim,
I believe I have solved my problem and I think it will work for you too.
If you set the fillMode of your animation to kCAFillModeBackwards you
should not see your layer until its beginTime has arrived.
I will file a bug against the docs as they need more detail around
fillMode.
HTH,
-bd-
http://bill.dudney.net/roller/objc
On Jan 25, 2008, at 4:01 AM, Joachim wrote:
This is a follow-up to http://lists.apple.com/archives/Cocoa-dev/2008/Jan/msg01182.html
.
I now have an animation that makes a pop while fading in. This works
great. It gets called implicitly for all my sublayers via the
[rootLayer addSublayer:layer] call, as the layer implements an
actionForKey: method that returns the CAAnimationGroup (see code
snippet at the end).
However, for all the layers that are added in one round, the
animations runs at the exact same time. I'd like to add a bit of
randomness by starting the animations slightly offset to each other.
So I've been experimenting with CAMediaTiming's timeOffset and
beginTime properties. But adding one of these messes the animation up.
If I set group.beginTime = CACurrentMediaTime () + 1.0; the layer
first appears right away (using the default animation, fading in
over 0.25s, I guess), and 1 second after disappears and does the
expected animation.
If I set group.timeOffset = 1.0; the animation is just offset so
that it starts 1 second into the animation and "wraps around" and
stops after <groups.duration> seconds. After that the layer is
simply displayed.
- I guess the beginTime is the right way to go - I just need the
layer not to appear before the animation starts a bit later. Any
ideas?
Initially setting the layer to hidden or opacity = 0, makes solves
that problem, but also makes the layer disapear again after the
animation, and I'd like to avoid forcing it to stay visible in the
animationDidStop:finished: delegate method (also makes the layer
flicker).
- Should I abandon the actionForKey: scenario and make the animation
happen by other means?
Joachim
- (id<CAAction>)actionForKey:(NSString *)key
{
if ([key isEqualToString:kCAOnOrderIn])
{
CABasicAnimation *alphaAnim = [CABasicAnimation
animationWithKeyPath:@"opacity"];
[snip]
CAKeyframeAnimation *sizeAnim = [CAKeyframeAnimation
animationWithKeyPath:@"transform.scale"];
[snip]
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = [NSArray arrayWithObjects:alphaAnim, sizeAnim,
nil];
group.duration = 1.0;
group.beginTime = CACurrentMediaTime () + 0.5;
//group.timeOffset = 0.5;
return group;
}
else
return nil;
}
_______________________________________________
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