Support our Sponsors:
Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2009, 07:42 PM
Heber Heber is offline
Junior Member
 
Join Date: Jun 2009
Location: Lindon, Utah
Posts: 5
Default CABasicAnimation

I am using CABasicAnimations to animate CALayers. I animate a property (like "position") from it's current value to a new value. I add the animation to a CALayer, and the animation runs.

However, as soon as the animation ends, the position property jumps back to it's original value. I'd like it to retain the ending value from the animation. Is there something I'm missing here?

(I'm using a CABasicAnimation so that I can control the duration of the animation, so I may just need to use a different approach..?)
Reply With Quote
  #2  
Old 07-02-2009, 02:48 AM
NickFalk's Avatar
NickFalk NickFalk is offline
Senior Member
 
Join Date: Mar 2009
Location: Oslo, Norway
Posts: 731
Default

Perhaps something like...
Code:
[CALayer setAnimationBeginsFromCurrentState:YES];
...is what you're looking for?

It's always easier for people to comment if you include some code-snippets by the way.
Reply With Quote
  #3  
Old 07-03-2009, 02:06 PM
Heber Heber is offline
Junior Member
 
Join Date: Jun 2009
Location: Lindon, Utah
Posts: 5
Default

Thank you for your response! I'm a first-time forum contributor, and it's exciting to see people helping each other

As to your suggestion, from what I can tell, setAnimationBeginsFromCurrentState is a method on UIView, not CALayer (though I did play around with it, and it does work as expected)

Here is a snippet of code
Code:
	CAKeyframeAnimation *slideAnimation = [CAKeyframeAnimation animation];
	slideAnimation.path = slidePath;
	slideAnimation.duration = SLIDE_PAPER_IN_DURATION;
	CGPathRelease(slidePath);
	[layerPaper addAnimation:slideAnimation forKey:@"position"];
In the above code, layerPaper starts in position 'A'.
The slidePath starts at position 'A' and ends at position 'B'.

The behavior I want is: when slideAnimation ends, layerPaper will remain in position 'B'.

However, what I am seeing is: when the animation ends, the layer jumps back to position 'A' (presumably because the animation was removed from the layer)

I try with a delegate to 'manually' set the layerPaper position to 'B' when the animation finishes, but sometimes get a flicker (of it jumping back to 'A', and then being set to 'B')

Any thoughts?
Thanks again!
Reply With Quote
  #4  
Old 07-03-2009, 11:28 PM
drunknbass drunknbass is offline
Senior Member
 
Join Date: Nov 2008
Posts: 128
Default

Quote:
Originally Posted by Heber View Post
Thank you for your response! I'm a first-time forum contributor, and it's exciting to see people helping each other

As to your suggestion, from what I can tell, setAnimationBeginsFromCurrentState is a method on UIView, not CALayer (though I did play around with it, and it does work as expected)

Here is a snippet of code
Code:
	CAKeyframeAnimation *slideAnimation = [CAKeyframeAnimation animation];
	slideAnimation.path = slidePath;
	slideAnimation.duration = SLIDE_PAPER_IN_DURATION;
	CGPathRelease(slidePath);
	[layerPaper addAnimation:slideAnimation forKey:@"position"];
In the above code, layerPaper starts in position 'A'.
The slidePath starts at position 'A' and ends at position 'B'.

The behavior I want is: when slideAnimation ends, layerPaper will remain in position 'B'.

However, what I am seeing is: when the animation ends, the layer jumps back to position 'A' (presumably because the animation was removed from the layer)

I try with a delegate to 'manually' set the layerPaper position to 'B' when the animation finishes, but sometimes get a flicker (of it jumping back to 'A', and then being set to 'B')

Any thoughts?
Thanks again!
please read up on implicit vs explicit animations.
http://developer.apple.com/documenta...ingLayers.html
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 2012, TouchArcade.com, LLC.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright 2008 - 2011, TouchArcade.com. Privacy Policy / DMCA Copyright Agent