在当前图像停止动画 [英] Stop animation at current image

查看:152
本文介绍了在当前图像停止动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动画图像,直到你preSS,上面写着停止按钮。
的code ++工程和所有,但图像返回到阵列中的第一图像。我如何添加一个code,告诉它停在它目前的形象?

   - (无效)viewDidLoad中{    [超级viewDidLoad中];    imageView.animationImages = [NSArray的arrayWithObjects:
                             [UIImage的imageNamed:@a0001.png],
                             [UIImage的imageNamed:@a0002.png],
                             [UIImage的imageNamed:@a0003.png],
                             [UIImage的imageNamed:@a0004.png],
                             [UIImage的imageNamed:@a0005.png],无]    imageView.animationDuration = 3.00;
    imageView.animationRepeatCount = 0;
    [ImageView的startAnimating]
    [self.view addSubview:ImageView的]。
} - (IBAction为)stopAni {
    [ImageView的stopAnimating]
}

感谢


感谢院长,嘿,我需要你再次:对,现在我已经能够阻止它,我想,我可以让它继续在那里已经停止动画?


<类DIV =h2_lin>解决方案

设置的UIImageView形象属性为要停止那个在

   - (IBAction为)stopAni {
    [ImageView的stopAnimating]
    [ImageView的setImage:[ImageView的animationImages] objectAtIndex:设置currentFrame];
}

当前框架仅仅是动画的持续时间由你一直animatin(你必须存储你开始自己制作动画的时候!)

的时间量除以

I have an image that is animating, until you press the button that says "Stop". The code works and all, but the image returns to the first image in the array. How can i add a code to tell it to stop at the image it's currently at?

- (void)viewDidLoad {

    [super viewDidLoad];

    imageView.animationImages = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"a0001.png"],
                             [UIImage imageNamed:@"a0002.png"],
                             [UIImage imageNamed:@"a0003.png"],
                             [UIImage imageNamed:@"a0004.png"],
                             [UIImage imageNamed:@"a0005.png"], nil];

    imageView.animationDuration = 3.00;
    imageView.animationRepeatCount = 0;
    [imageView startAnimating];
    [self.view addSubview:imageView];   
}

- (IBAction)stopAni {       
    [imageView stopAnimating];      
}

Thanks


Thanks dean, hey I need you once again :p now I've been able to stop it where I want, can I make it continue the animation where it has stopped??

解决方案

Set the image property of the UIImageView to be the one you want to stop at

- (IBAction)stopAni {
    [imageView stopAnimating];
    [imageView setImage:[[imageView animationImages] objectAtIndex:currentFrame];
}

The current frame is just the animation duration divided by the amount of time that you have been animatin (you'll have to store the time that you started animating yourself!)

这篇关于在当前图像停止动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆