I'm a new developer. My question is: is there a direct way to get the x,y position of an animated view in the middle of the animation?
I have this code (from the Stanford iPhone course in youtube) that moves the stalker UIView to the position of the touch:
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[UIView beginAnimations:@"stalk" context:nil];
UITouch *touch = [touches anyObject];
[UIView setAnimationDuration:10];
[UIView setAnimationBeginsFromCurrentState:YES];
stalker.center = [touch locationInView:self];
[UIView commitAnimations];
}
I want to modify the code such that stalker will not move to the touch location but to a different location I want to calculate, which is relative on the stalker view position at the time of the touch.
It should be possible to do by calculating the time passed from the beginning of the animation till the touch, but I want to ask if there's a more direct way. I assume that the current x,y are stored somewhere under the hood - the question is how to access them.
Thanks!