Animating frame change of UIView is not smooth, results in a bouncy effect

14,946

Solution 1

On animating the frame change of each of the subviews individually did the magic. Now it animates very smoothly. Thanks.

Solution 2

You could try to change the animation curve, maybe try the linear one.

dispatch_async(dispatch_get_main_queue(), ^{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    self.view.frame = newFrame;
    [UIView commitAnimations];
});
Share:
14,946
Soumya Das
Author by

Soumya Das

Updated on June 16, 2022

Comments

  • Soumya Das
    Soumya Das almost 2 years

    I am trying to animate the frame change of an UIView where both the origin and the size changes. The animation doesn't look smooth and has got a bouncy effect. I am using the following code to do that

    [UIView
        animateWithDuration:0.5
        animations:^{
            self.view.frame = newFrame;
        }];
    

    It seems that the size first changes very fast and then the origin changes with the specified duration of the animation which finally results in a bouncy effect. How do I make this look smooth?

  • Soumya Das
    Soumya Das over 12 years
    I had already tried using UIViewAnimationCurveLinear but it didn't work. The size is changed immediately and then the animation for the position change kicks in.
  • Mellson
    Mellson over 12 years
    have you tried using the entire block of code? I just tried it - and both the size and origin animates smoothly at the same time
  • Soumya Das
    Soumya Das over 12 years
    Got it right now. I had to animate all the subviews individually else it has got this bounce effect. Thanks.
  • coolcool1994
    coolcool1994 almost 9 years
    this doesn't change the size of the the self.view. It only moves it.