improving transition smoothness in view

568 views Asked by At

In our application we use CATransition for transition from one view to another, but we are missing the smoothness like in others apps . hence what can be alternate solution for view transition or some tips to improve applicaton flow smoothness.

Regards

Edited here is the code we are using:

MyView *obj =[[MyView alloc]initWithFrame:CGRectMake(0,0,320,415)];
CATransition *animation = [CATransition animation];
[animation setDuration:0.3];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animation setType:kCATransitionPush]; 
[animation setSubtype:kCATransitionFromRight];  
[[self.superview layer] addAnimation:animation forKey:nil];

[self.superview addSubview:obj];
[obj release];

[self removeFromSuperview];
1

There are 1 answers

2
eric.mitchell On

It's going to be hard to help you without any code/background information, but one things I can tell you is rasterization during animation can make a huge difference:

- (void)startAnimation {
    [myView.layer setShouldRasterize:YES]; //tell the layer to rasterize
    [myView.layer setRasterizationScale:[UIScreen mainScreen].scale]; //make sure it scales on retina devices

    double delayInSeconds = 0.1; // wait a bit to let it rasterize
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_current_queue(), ^(void) {
        //do
        //your
        //animation
        //here

        //where you're animation is finished (i.e. in a completion block)
        //tell the layer not to rasterize anymore
        [myView.layer setShouldRasterize:NO];
    }
}