PDA

View Full Version : Core Animation: Keep object at final animation location




99miles
Jun 19, 2009, 11:37 AM
How do I keep an object in the location it ends up in at the end of an animation?

The docs say that implicit animations should occur by default when you set a property, however I don't see that happening.

So I have an animation where I move a UIView down like this:


CABasicAnimation *moveDown;
moveDown = [CABasicAnimation animationWithKeyPath:@"position.y"];
moveDown.toValue = [NSNumber numberWithFloat:54];
moveDown.duration = 0.5;
moveDown.removedOnCompletion = NO;
moveDown.fillMode = kCAFillModeForwards;
[[bucketView.characterImageView layer] addAnimation:moveDown forKey:@"y"];


I want the object to remain in the location it's in at the end of the animation, that's why I set 'removedOnCompletion' and 'fillMode'. This works, but if I later try to change the frame of this view it doesn't do anything.


CGRect frame = bucketView.characterImageView.frame;
frame.origin.y = 50;
bucketView.characterImageView.frame = frame;


What's the simplest way to achieve this?