gpt4 book ai didi

iphone - Object-c 如何在不同的持续时间内为不同的图像集一个接一个地制作动画(iphone)

转载 作者:行者123 更新时间:2023-12-03 20:28:13 24 4
gpt4 key购买 nike

我需要依次制作 10 组图像(10 个图像数组)的动画每组动画的持续时间不同。我尝试使用 UIImageView 来做到这一点,如下所示:

[myImageView1 setAnimationImages:imagesSet1];
[myImageView1 setAnimationRepeatCount:0];
[myImageView1 setAnimationDuration:2];
[myImageView1 startAnimation];


[myImageView1 setAnimationImages:imagesSet2];
[myImageView1 setAnimationRepeatCount:0];
[myImageView1 setAnimationDuration:5];
[myImageView1 startAnimation];

但这不起作用,它显示了最后的图像。

最佳答案

试试这个代码:

 NSArray *array1=[[NSArray alloc] initWithObjects:[UIImage imageNamed:@"ballImg1.png"],[UIImage imageNamed:@"ballImg3.png"],[UIImage imageNamed:@"ballImg4.png"],[UIImage imageNamed:@"ballImg5.png"],nil];

NSArray *array2=[[NSArray alloc] initWithObjects:[UIImage imageNamed:@"ballAniImg1.png"],[UIImage imageNamed:@"ballAniImg3.png"],[UIImage imageNamed:@"ballAniImg4.png"],[UIImage imageNamed:@"ballAniImg5.png"],nil];

NSArray *array3=[[NSArray alloc] initWithObjects:[UIImage imageNamed:@"ballRotImg1.png"],[UIImage imageNamed:@"ballRotImg3.png"],[UIImage imageNamed:@"ballRotImg4.png"],[UIImage imageNamed:@"ballRotImg5.png"],nil];

array4=[[NSArray alloc] initWithObjects:array1,array2,array3,nil];

i1=0;
[self performSelector:@selector(animation1:) withObject:[NSNumber numberWithFloat:2.0] afterDelay:0];
i=0;



-(void)animation1:(NSNumber*)k
{
if(i1<[array4 count])
{
int m1=[k floatValue];
NSArray *arr1= [array4 objectAtIndex:i1];
myImageView1.animationImages=arr1;
myImageView1.animationDuration=m1;
myImageView1.animationRepeatCount=1;
[myImageView1 startAnimating];
i1++;
[self performSelector:@selector(animation1:) withObject:[NSNumber numberWithFloat:2.0] afterDelay:3.0];

}
}

关于iphone - Object-c 如何在不同的持续时间内为不同的图像集一个接一个地制作动画(iphone),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7995135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com