user1010046
user1010046

Reputation: 31

How to get UIImageView real location in view while animation?

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

Upvotes: 3

Views: 2153

Answers (1)

Simon Lee
Simon Lee

Reputation: 22334

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];

Upvotes: 4

Related Questions