2012-08-15 105 views
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]; 

回答

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]; 
    } 
} 
+0

已经编辑我的问题和提供的代码block..tried运用光栅化,但它不是挣到那么多迪菲昂斯 – 2012-08-16 05:58:24

+0

你不能使用简单的UIView动画吗?为什么你需要核心动画?另外,尝试栅格化* superview *,而不是视图本身。 – 2012-08-16 12:35:52