在视野中改善过渡平稳性

时间:2012-08-15 13:29:09

标签: ios animation uiview catransition multiple-views

在我们的应用程序中,我们使用CATransition从一个视图转换到另一个视图,但我们错过了其他应用程序中的平滑性。因此,什么可以成为视图转换的替代解决方案或一些提高应用流平稳性的技巧。

此致

这里编辑的是我们正在使用的代码:

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 个答案:

答案 0 :(得分:0)

在没有任何代码/背景信息的情况下帮助你很难,但我可以告诉你的一件事是动画期间的光栅化会产生很大的不同:

- (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];
    }
}