动画效果一风火轮加载效果/动态图展示
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了动画效果一风火轮加载效果/动态图展示相关的知识,希望对你有一定的参考价值。
#import "ViewController.h"
@interface ViewController ()
// 可视化编程拖出的UIImageView属性
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
// 定义数组存放图片组
@property (nonatomic,strong)NSMutableArray *imagesArr;
// 定义活动指示器(风火轮)属性
@property (nonatomic,strong)UIActivityIndicatorView *activity;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.imagesArr = [NSMutableArray array];
[self setImageAnimation];
[self setActivityAnition];
}
- (void)setImageAnimation{
self.imageView.backgroundColor = [UIColor lightGrayColor];
// 添加到数组
for (int i = 1; i < 14; i++) {
UIImage *tempImage = [UIImage imageNamed:[NSString stringWithFormat:@"%d",i]];
[self.imagesArr addObject:tempImage];
}
// 设置动画时长
self.imageView.animationDuration = 5.0;
// 设置动画数组
self.imageView.animationImages = self.imagesArr;
// 设置重复的次数(-1代表无限制)
self.imageView.animationRepeatCount = -1;
}
- (void)setActivityAnition{
// 初始化风火轮
self.activity = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];
// 设置样式
self.activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
// 添加到要展示的视图上
[self.imageView addSubview:self.activity];
}
// 开始按钮
- (IBAction)startAnimationAction:(UIButton *)sender {
[self.imageView startAnimating];
}
// 停止按钮
- (IBAction)stopAnimationAction:(UIButton *)sender {
[self.imageView stopAnimating];
}
// 开始
- (IBAction)start:(UIButton *)sender {
[self.activity startAnimating];
}
// 结束
- (IBAction)stop:(UIButton *)sender {
[self.activity stopAnimating];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
以上是关于动画效果一风火轮加载效果/动态图展示的主要内容,如果未能解决你的问题,请参考以下文章