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];
4

1 回答 1

-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
于 2013-07-31T08:52:57.130 回答