How to get UIImageView real location in view while animation?

2.1k views Asked by At

Hi all,


For the animation i used:

[UIView commitAnimation:@"anim" context:nil];
[UIView setAnumatioDuration:10];
imageView.center=CGPointMake(100,100);
[UIView commitAnimation];


The thing is that when i call with timer every 0.5 seconds:

CGRect rect=[[imageview.layer presentationLayer]frame];
CGPoint point=rect.origin;
NSLog(@"x:%f,y:%f",origin.x,origin.y);


I will always get x:100,y:100
And I what i want to get is the true location on the view
while the imageview heading to (100,100)

10x a lot

1

There are 1 answers

4
Simon Lee On

Animations are updated on the presentation layer of a view. You can retrieve the values representing the current state of the image view during an animation by looking at this layer.

CGPoint center = [[imageView.layer presentationLayer] center];