3

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
sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
  • 3
    Benny, first of all, signatures are not allowed per the FAQ. Also, you don't need to write your question in HTML. StackOverflow lets you use Markdown formatting, so you can just write in plain text. ;) – sudo rm -rf Oct 24 '11 at 04:12

1 Answers1

4

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];
Simon Lee
  • 22,304
  • 4
  • 41
  • 45
  • That looks basically the same as what he's doing, except he's trying to get the origin from the frame property, instead of the center. But it should work the same, no? – acjay Oct 25 '11 at 16:42
  • No, the properties on the object frame will immediately be set to their final positions, however the presentation layer will transition the properties from their original to their new position, so you can query that layer at any time and get the current position during an animation, using the object layer does not provide this. – Simon Lee Oct 26 '11 at 08:43
  • 1
    But he is using the presentation frame, this is what he wrote: CGRect rect=[[imageview.layer presentationLayer]frame]; – acjay Oct 27 '11 at 05:48
  • 2
    Don't forget to add QuartzCore.framework and include "QuartzCore/QuartzCore.h" in your code. – antonio081014 Oct 22 '13 at 00:25