I want an image view of some size say 25 by 25, to move in a linear motion from left to right and then right left continuously.
Lets say the image starts moving from left, then at the time it reaches reaches the right, it should start moving back to the left, then this should repeat.
I have this code, which lets the view move down, but I am unable to move it back and forth. This is for UIView.
[UIView beginAnimations:@"MyAnimation" context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:45.0]; // 5 seconds
frame = movingView.frame;
//int j = frame.origin.y;
int i;
for (i= 0; i<=100; i++) {
frame.origin.y += i;//100.0; // Move view down 100 pixels
movingView.frame = frame;
}
How should i do this?
Regards