title: Move image from left to right and right to left in iphone
body: <pre><code>- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
              curve:(int)curve x:(CGFloat)x y:(CGFloat)y
  {
      // Setup the animation
      [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationDuration:duration];
      [UIView setAnimationCurve:curve];
      [UIView setAnimationBeginsFromCurrentState:YES];
  
      // The transform matrix
      CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
      image.transform = transform;
  
      // Commit the changes
      [UIView commitAnimations];
  }
  </code></pre>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];    
      UIImageView *imageToMove = 
      [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon.png"]];
      imageToMove.frame = CGRectMake(10, 10, 20, 20);
      [self.view addSubview:imageToMove];
  
      // Move the image
      [self moveImage:imageToMove duration:3.0 
                curve:UIViewAnimationCurveLinear x:50.0 y:50.0];  
  
  }</code></pre>
  
  <p>I have tried this one.It works fine at one time from left to right.But i need to move the image from left and right to left repeatedly.</p>
  
  <p>Thanks in advance.</p>