如何在按钮内动画进度?

时间:2018-04-07 09:46:42

标签: objective-c core-animation

我的View Controller中有一个语音按钮。下面附有图像。 enter image description here

我想在执行某些功能时使用循环进度指示器为此图像设置动画。我怎样才能实现这个动画?

1 个答案:

答案 0 :(得分:0)

设置后面的imageview按钮。

将此代码放在按钮操作上。

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                               [UIImage imageNamed:@"image1.gif"],
                               [UIImage imageNamed:@"image2.gif"],
                               [UIImage imageNamed:@"image3.gif"],
                               [UIImage imageNamed:@"image4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView]; 

你可以使用这个技巧在按钮上加载gif图像背景。

相关问题