title: animating in 3 steps one after the other ios
body: <p>I have 3 cards. at first all cards move to the right, then after 1 sec card2 would appear on the left side of the view, and then after some more second card2 moves to the right. I implemented this using the following code. when the view loads I have the following code,</p>
  
  <pre><code>counter = 0;
  timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(performAnimationToRight) userInfo:nil repeats:YES];
  </code></pre>
  
  <p>here is the implementation of the performAnimationToRightMethod</p>
  
  <pre><code>-(void)performAnimationToRight
  {
  if (counter == 0) {
  
      CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(388,0);
  
      [UIView beginAnimations:@"Move1" context:nil];
      [UIView setAnimationDuration:2];
  
      card0.transform = transformToLeft;
      card1.transform = transformToLeft;
      card2.transform = transformToLeft;
  
      [UIView commitAnimations];
  
  }else if(counter == 50){
  
      card2.frame = CGRectMake(-300,card2.frame.origin.y, card2.frame.size.width, card2.frame.size.height);
  
  }else if(counter == 200){
  
      timer = nil;
      counter = 0;
      CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(-300,0);
  
      [UIView beginAnimations:@"Move2" context:nil];
      [UIView setAnimationDuration:2];
  
      card2.transform = transformToLeft;
  
      [UIView commitAnimations];
  }
  
  counter++;
  }
  </code></pre>
  
  <p>the problem is that on the last action card2 instead of moving to the right moves to the left, and that's wether or not I use, </p>
  
  <pre><code>    CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(-300,0);
  </code></pre>
  
  <p>or </p>
  
  <pre><code>    CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(+300,0);
  </code></pre>