0
votes

Tyring to animate a UIView by changing its height and position. The first animation jumps? I have the size of the UIView (theView) set in Storyboards to be height of 216. So the app loads and the theView is shown. I click theView and it quickly jumps in height to 200+ pixels then animates as it should?

- (void)singleTapAction:(UIGestureRecognizer *)singleTap {
UIView *view = singleTap.view;
[UIView animateWithDuration:1.2 delay:0 options:UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{
    CGRect theFrame = self.theView.frame;
    theFrame.size.height += 100.f;  <!-- when it hits here the view jumps then animates
    self.theView.frame = theFrame;
}
                 completion:^(BOOL finished) {
                     if(finished){
                         [UIView animateWithDuration:1.2 delay:0 options:UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{
                             CGRect theFrame = self.theView.frame;
                             theFrame.origin.y -= 100.f;
                             self.theView.frame = theFrame;
                         }
                                          completion:^(BOOL finished) {
                                              NSLog(@"animations complete");
                                          }];
                     }
                 }];

}

1
Not sure to understand your question. Just not, btw, that you have an "auto reverse" option in the UIView::animate . - Vinzius
@Vinzius you are correct. - jdog

1 Answers

0
votes

Try moving lines

CGRect theFrame = self.theView.frame;
theFrame.size.height += 100.f;  <!-- when it hits here the view jumps then animates

outside the block. Put it before the animation method is called.