2012-12-05 42 views
4

如何實現向右翻轉圖像翻轉動畫。代碼如下。 plz幫助。如何在iPhone應用程序中實現圖像翻轉動畫

imageview.animationImages=[NSArray arrayWithObjects: 
    [UIImage imageNamed:@"image1.png"], 
    [UIImage imageNamed:@"imag2.png"], 
    [UIImage imageNamed:@"imag3.png"], 
    [UIImage imageNamed:@"imag4.png"], 
    [UIImage imageNamed:@"imag5.png"], 
    [UIImage imageNamed:@"imag6.png"], 
    [UIImage imageNamed:@"imag7.png"], nil]; 

imageview.animationDuration=15.0; 
imageview.animationRepeatCount=0; 
[imageview startAnimating]; 
+1

什麼的方式有問題你做完了? –

+0

@威爾:這只是一個簡單的動畫。我怎樣才能將圖像向右翻轉? – Nila

回答

8

垂直翻轉

[UIView animateWithDuration:1.0 animations:^{ 
    yourView.layer.transform = CATransform3DMakeRotation(M_PI,1.0,0.0,0.0); 
} completion:^(BOOL finished){ 
    // code to be executed when flip is completed 
}]; 

的水平翻轉

[UIView animateWithDuration:1.0 animations:^{ 
    yourView.layer.transform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0); 
} completion:^(BOOL finished){ 
    // code to be executed when flip is completed 
}]; 

,不要忘了QuartzCore框架添加到項目和進口

#import <QuartzCore/QuartzCore.h> 
+0

我試過這個代碼。但我有一個錯誤。這是由於ios 4.0? – Nila

+0

這應該適用於iOS 4.0或更高版本,正在獲取什麼錯誤?未找到架構i386的符號(S) collect2: –

+0

爲i386硬件架構未定義符號: 「_CATransform3DMakeRotation」,從引用:在homeViewController.o LD ___- [homeViewController viewDidLoad中] _block_invoke_1 LD返回1個退出狀態 – Nila

2
[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.5]; 

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:imageview cache:NO]; 
[UIView commitAnimations]; 

我覺得這個代碼可以幫助你。

+0

它不工作 – Nila

+0

@nila圖像應該如何並排翻轉(垂直滾動)或像視圖控制器翻轉。 – alex

+0

並排翻轉 – Nila

相關問題