2013-07-31 25 views
0

我有我的數組中的3個圖像這個示例代碼,它只是沒有任何風格的動畫。我想要淡入淡出風格的動畫。從動畫風格的陣列動畫圖像

NSArray *imarray = [[NSArray alloc] initWithObjects: 
    [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/lady1_open.png", path]], 
    [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/lady1_open2.png", path]], 
    [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/lady1_open3.png", path]], 
    nil]; 

bingo_girl.animationImages=imarray; 
bingo_girl.animationDuration=5; 
bingo_girl.animationRepeatCount=0; 
[bingo_girl.layer addAnimation:transition forKey:nil]; 
[bingo_girl startAnimating]; 
+0

哪裏'transition'來自手動動畫過渡的圖像,例如?它是如何創建的等? –

+0

這個過渡只是改變一幀一幀,但不像我想要的。 – ThananutK

回答

-1

可以使用此類別

@implementation UIImageView (AnimateTransition) 
- (void) assignImage:(UIImage *)image withTransition:(NSString *)withTransition withDirection:(NSString *)withDirection{ 

if(image == nil) 
{ 
    [self setImage:nil]; 
    return; 
} 

if ([UIImagePNGRepresentation(self.image) isEqualToData:UIImagePNGRepresentation(image)])  { 
    return; 
} 

CATransition *animation = [CATransition animation]; 
animation.duration = 0.2; 
animation.type = withDirection; 
animation.subtype = withDirection; 
[[self layer] addAnimation:animation forKey:@"imageFade"]; 
[self setImage:image]; 
} 

@end 
+0

- (void)assignImage:(UIImage *)image withTransition:(NSString *)withTransition withDirection:(NSString *)withDirection;看起來像這種方法沒有與數組一起工作。或者我做錯了 – ThananutK

+0

這是一個圖像的方法。只需使用計時器遍歷圖像並應用此方法來更改UIImageView中的圖像 – nerowolfe