如何在 iOS 中为一组图像制作动画

发布于 2024-12-11 14:46:12 字数 636 浏览 0 评论 0原文

我有一组图像,我想要 UIImageView 对其进行动画处理,

我知道如何使用此方法执行此操作:

[myImageView setAnimationImages:myImageArray];
[myImageView setAnimationDuration:.7];
[myImageView setAnimationRepeatCount:1];
[myImageView startAnimating];

但是我想使用不同的方法。我想这样做

[UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction)
                 animations:^{
                     // animate image array
                 }
                 completion:^(BOOL finished){
                     //  [self animationEnded];
                 }
 ];

,但我不确定在我拥有的 // 动画图像数组中放置什么

I have an array of images that I want a UIImageView to animate

I know how to do this with this method:

[myImageView setAnimationImages:myImageArray];
[myImageView setAnimationDuration:.7];
[myImageView setAnimationRepeatCount:1];
[myImageView startAnimating];

However I want to use a different method. I want to do this

[UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction)
                 animations:^{
                     // animate image array
                 }
                 completion:^(BOOL finished){
                     //  [self animationEnded];
                 }
 ];

but I am not sure what to put where I have // animate image array

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2024-12-18 14:46:12

也许 [UIView setAnimationDelegate:self] 会对你有帮助?

[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];然后将执行你的animationDidStop::。

或者,如果您尝试坚持使用块,我认为这将是一系列嵌套的动画完整部分,例如

[UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction)
                 animations:^{
                     // Show first image
                 }
                 completion:^(BOOL finished){
                     // Hide first image
                     [UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction) animations:^{
                     // Show second image
                    }
                    completion:^{
                        // Hide second image
                    }
                 }

Maybe [UIView setAnimationDelegate:self] will help you?

[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; will perform your animationDidStop:: then.

Or, if you are trying to stick with blocks, I think it would be a series of nested animations-complete sections like

[UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction)
                 animations:^{
                     // Show first image
                 }
                 completion:^(BOOL finished){
                     // Hide first image
                     [UIView animateWithDuration:.7 delay:0 options:(UIViewAnimationOptionAllowUserInteraction) animations:^{
                     // Show second image
                    }
                    completion:^{
                        // Hide second image
                    }
                 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文