xiaowoo
xiaowoo

Reputation: 2308

how to improve the performance of a laggy UIView animation

i am trying to apply a flip transition from my current view controller to the next view controller. its working but its has noticeable lag(very noticeable). so, i would like to ask, do you guys have any suggestion/solutions to improve this uiview animation for flipping from one view controller to another?

here is a snippet of my code, and thanks for reading, appreciate any helpful comments/suggestions. thanks

[UIView animateWithDuration:0.50 delay:0.00 options:0 animations:^{
    [self.navigationController pushViewController:viewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
} completion:^(BOOL finished) {

}];

Upvotes: 3

Views: 2149

Answers (1)

coneybeare
coneybeare

Reputation: 33101

The problem isn't really in how you call the animation, but in the drawing code you have for the views. If you optimize the logic and time required for rendering the views in those controllers, I guarantee you will see better performance in the animations between them.

You could try turning on the cache argument that you have currently set to NO to see if that helps in the short term, but it really is a bandaid, not a cure.

Also, with a frame rate of 60fps at best, a .5 second animation is going to have only 30 frames to work with at most. If you increase the animation duration a little, it will appear to be smoother once you have the view rendering optimized.

Upvotes: 6

Related Questions