使用动画样式从数组中动画图像

时间:2013-07-31 06:58:06

标签: uiimageview uiviewanimation

我的数组中有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];

1 个答案:

答案 0 :(得分:-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