2012-08-15 67 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