title: After Animation, View position resets
body: <p>I am trying to make a view slide from top to bottom. This is not a big deal, I used <code>CABasicAnimation</code> for this. The problem is when I want to remove the view. I use this animation.</p>
  
  <pre><code>CABasicAnimation *animation;
  animation = [CABasicAnimation animationWithKeyPath:@"position"];
  [animation setDelegate:self];
  animation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.layer.position.x, 0 - self.view.bounds.size.height / 2)];
  animation.fromValue = [NSValue valueWithCGPoint:self.view.layer.position];
  animation.autoreverses = NO;
  animation.repeatCount = 0;
  animation.duration = 0.25;
  animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
  [self.view.layer  addAnimation:animation forKey:@"moveX"];
  </code></pre>
  
  <p>Which animates the view perfectly. But, after the animation finishes, my view appears again. So I added this line :</p>
  
  <pre><code>[self.view removeFromSuperview];
  </code></pre>
  
  <p>Which removes the view, but with no animation. So I decided to add the remove code to this delegate:</p>
  
  <pre><code>-(void) animationDidStop:(CAAnimation *) animation finished:(bool) flag
  </code></pre>
  
  <p>So now, the animation works, the view disappears, but sometimes, I can see the view appear and disappear faster, is like after the animation, the view appears, then the <code>animationDidStop</code> delegate is called, and the view disappears, obviously this is awful. What am I doing wrong?</p>