0

On didSelectRowAtIndexPath, I am reloading selected row and changing heightForRowAtIndexPath so that selected tableview cell can expand. This is working fine. So as soon reloading expanding done I have to animate a UIView which is in the back of a UIImageView.

Animation should be like its coming from behind of imageView and stop at certain position like its revealing from image. It should be simple ? by changing y origin and doing in it animation block.

But the problem is its not at all animating with simple UIView beginAnimations code. I think it should be possible using CAKeyframeAnimation applying to the layer of UIView.

I have never played with layers. Can anybody guide me ?

Thanks

Tariq
  • 9,514
  • 11
  • 55
  • 97

1 Answers1

1

You could try something like this:

CABasicAnimation *myViewAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
[myViewAnimation setFromValue:[NSValue valueWithCGPoint:CGPointMake(INITIAL_X,INITIAL_Y)]];
[myViewAnimation setToValue:[NSValue valueWithCGPoint:CGPointMake(FINAL_X,FINAL_Y)]];
[myViewAnimation setDuration:0.5];
[myView.layer setPosition:CGPointMake(FINAL_X,FINAL_Y)];
[myView.layer addAnimation:myViewAnimation forKey:@"position"];

You'll need to link the QuartzCore framework to your project and import it (#import <QuartzCore/QuartzCore.h>)

sooper
  • 5,791
  • 6
  • 36
  • 64