如何在 UIView 的不同位置为多个图像提供图像动画? [英] How to give image Animations to multiple images at Different Locations in a UIView?

查看:35
本文介绍了如何在 UIView 的不同位置为多个图像提供图像动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Different 处为 多个图像 提供图像"动画UIView"中的位置?

How to give 'image' Animations to multiple images at Different Locations in a 'UIView'?

1) 我有 3 张图片.

1) I had 3 images.

2) 我想在 3 个不同的位置 以动画方式添加这些 3 个图像,这意味着使用 动画 添加一张图像一些持续时间??

2) i want to Add these 3 Images at 3 different locations animatedly, means add one by one images animatedly with some duration??

我怎样才能做到这一点?

推荐答案

根据您的要求,您想要一张一张的动画

As per your requirement you want to animate image one by one

为此目的使用第一个图像动画的完成块来动画第二个图像等等

for that purpose use completion block of first image animation to animate second image and so on like below code

UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",1]]];
[imgView setBackgroundColor:[UIColor redColor]];

UIImageView *imgView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",2]]];
[imgView2 setBackgroundColor:[UIColor redColor]];

UIImageView *imgView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",2]]];
[imgView3 setBackgroundColor:[UIColor redColor]];

[self.view addSubview:imgView];
[self.view addSubview:imgView2];
[self.view addSubview:imgView3];

[UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{

    [imgView setFrame:CGRectMake(0, 0, 150, 150)];


} completion:^(BOOL finished) {

    [UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
        [imgView2 setFrame:CGRectMake(self.view.frame.size.width - 150, 0, 150, 150)];

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
            [imgView3 setFrame:CGRectMake(0, self.view.frame.size.height - 150, 150, 150)];

        } completion:^(BOOL finished) {


        }];

    }];

}];

它会帮助你:)

这篇关于如何在 UIView 的不同位置为多个图像提供图像动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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