2012-01-03 57 views
0

我有一個視圖(UIViewController的默認設置),上面的圖像視圖和頂部的工具欄。如何爲UIview的某個部分設置動畫

 Toolbar 
     --------- 
    UIImageView 
    ----------- 
     UIView 

這是基本結構。我想動畫UIView的和唯一的UIImageView不工具欄上,目前我使用的代碼

CATransition *animation = [CATransition animation]; 

[animation setDelegate:self]; 
[animation setType:kCATransitionPush]; 

if ([directionScrolled isEqualToString:@"1"]) { 
    [animation setSubtype:kCATransitionFromRight]; 
} 
else if([directionScrolled isEqualToString:@"2"]){ 
    [animation setSubtype:kCATransitionFromLeft]; 
} 

[animation setDuration:0.20]; 
[animation setTimingFunction: 
[CAMediaTimingFunction functionWithName: 
    kCAMediaTimingFunctionDefault]]; 


[[self.view layer] addAnimation:animation forKey:kCATransition]; 

動畫整體視圖,(與工具欄一起)。我想從動畫中排除工具欄。

+0

把你的ImageView和視圖單獨視圖和該視圖應用動畫。 – aViNaSh 2012-01-03 05:08:41

+0

@aViNaSh我試過了,但動畫轉換之間出現了一個白色陰影。我想在scrollView中啓用分頁的外觀就像一樣。 – rakeshNS 2012-01-03 07:22:32

回答

0

您可以重新排列你的UI結構是這樣

 
     UIView (this view is assigned to UIViewController) 
     | 
     |------Toolbar 
     |------UIView (lets take another UIView and name it as myView) 
       |-------UIImageView 

然後執行你的相同的代碼。 除此之外,

 last line will be [[self.myView layer] addAnimation:animation forKey:kCATransition];

確保

+0

問題是動畫時會出現白色陰影。 – rakeshNS 2012-01-03 08:07:41

相關問題