使用UIView动画块进行UIImageanimation

时间:2012-08-07 14:39:47

标签: iphone animation uiview uiimageview

我想使用UIView Animation和块而不是UIImageview Animation。因为我需要知道动画何时完成,所以我决定使用UIView Animation和我不熟悉的块。 所以我想要这个:

NSMutableArray *mixedimages = [[NSMutableArray alloc] initWithCapacity:5];

for(int count = 1; count <= 5; count++)
    {
        NSString *fileName = [NSString stringWithFormat:@"Picture_%d.jpg", count];
        UIImage  *frame    = [UIImage imageNamed:fileName];
        [mixedimages addObject:frame];
    }


gamePicture.animationImages = mixedimages;

gamePicture.animationDuration = 1;
gamePicture.animationRepeatCount = 10;

[gamePicture startAnimating];

进入这个:

[UIView animateWithDuration:1 animations:^{

    //animation code here
} completion:^(BOOL finished)
{
    NSLog(@"Animation finished");
}];

但是我不知道要填写的代码与上面相同,所以我将使用相同类型的动画。

1 个答案:

答案 0 :(得分:0)

您无法使用UIView动画为UIImageView的内容制作动画。 UIView动画只能为一组固定的UIView属性设置动画:

@property frame
@property bounds
@property center
@property transform
@property alpha
@property backgroundColor
@property contentStretch

要解决UIImageView缺少完成块的问题,可以参考这里的答案:

iPhone : Best way to detect the end of UIImageView image sequence animation