Get the coordinates of an animated UIImageview

I animate UIImageview horizontally for this purpose, I used the code below, I used NSTimer

timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; -(void)onTimer { [UIView animateWithDuration:10.0f animations:^{ //Moving_Cloud is an image view Moving_Cloud.frame = CGRectMake(200.0f, 150.0f, Moving_Cloud.frame.size.width, Moving_Cloud.frame.size.height); }]; } 

now the problem I am facing is that I need to get the coordinates of "Moving_Cloud" after the duration of the animation
Please help me
Thanks in advance.

+3
source share
2 answers

Abhijit Chaudhari from a comment in my previous post I understand that you do not want the position "after the duration of the animation", but instead the position during the animation.

If I still do not understand, please clarify your question. (Or buy me a new brain)

 -(void) animateMe(){ NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES]; [UIView animateWithDuration:10.0f animations:^{ //Moving_Cloud is an image view Moving_Cloud.frame = CGRectMake(200.0f, 150.0f, Moving_Cloud.frame.size.width, Moving_Cloud.frame.size.height); }]; } -(void)onTimer:(id)sender{ NSLog(@"Currently in x=%f", [[ddddd.layer presentationLayer] frame].origin.x); NSLog(@"Currently in y=%f", [[ddddd.layer presentationLayer] frame].origin.y); } 
+1
source
 [UIView animateWithDuration:10.0f animations:^{ Moving_Cloud.frame = CGRectMake(200.0f, 150.0f, Moving_Cloud.frame.size.width, Moving_Cloud.frame.size.height); } completion:^(BOOL finished){ CGPoint newPost = Moving_Cloud.frame.origin; CGFloat xPos = newPost.x; CGFloat yPos = newPost.y; // do stuff ? }]; 

At the end of your animation, the "end:" block will be launched.

Usually your image should be at x = 200, y = 150.

Keep in mind that these coordinates relate to this superwin (viewing the Moving_Cloud view).

Note:
By convention, I recommend changing "Moving_Cloud" to "movingCloud".

The instance class begins with the bottom cover in objective-C.
Also, do not use _, but instead capital letter.

+1
source

All Articles