2

在我们的应用程序中,我们使用 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];
4

1 回答 1

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];
    }
}
于 2012-08-15T14:47:59.723 回答