如何在iPhone中启动和停止图像动画

时间:2021-04-04 21:15:32

How can I start and stop image animation using button control?

如何使用按钮控制启动和停止图像动画?

imageView.animationImages = [NSArray arrayWithObjects: 
[UIImage imageNamed:@"p1.jpg"],[UIImage imageNamed:@"p2.jpg"], [UIImage imageNamed:@"p3.jpg"],[UIImage imageNamed:@"p4.jpg"],[UIImage imageNamed:@"p5.jpg"],[UIImage imageNamed:@"p6.jpg"], nil]; 

imageView.animationDuration = 1.00; //1 second
imageView.animationRepeatCount = 0; //infinite

[imageView startAnimating]; //start the animation

1 个解决方案

#1


1  

Add two buttons using Interface Builder, create two IBAction methods in your controller, connect Touch Up Inside events with the IBActions. Use [imageView startAnimating] to start, [imageView stopAnimating] to stop.

使用Interface Builder添加两个按钮,在控制器中创建两个IBAction方法,将Touch Up Inside事件与IBActions连接。使用[imageView startAnimating]启动,[imageView stopAnimating]停止。

#1


1  

Add two buttons using Interface Builder, create two IBAction methods in your controller, connect Touch Up Inside events with the IBActions. Use [imageView startAnimating] to start, [imageView stopAnimating] to stop.

使用Interface Builder添加两个按钮,在控制器中创建两个IBAction方法,将Touch Up Inside事件与IBActions连接。使用[imageView startAnimating]启动,[imageView stopAnimating]停止。