Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 494
Soumya Das Avatar asked Nov 09 '11 11:11

Soumya Das


2 Answers

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];
});
like image 128
Mellson Avatar answered Nov 18 '22 20:11

Mellson


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

like image 34
Soumya Das Avatar answered Nov 18 '22 21:11

Soumya Das