风火轮(菊花加载)
1 // 加载旋转的菊花效果[UIActivityIndicatorView实现加载风火轮效果] 2 // 无需设置frame 3 UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 4 indicatorView.center = self.view.center; 5 [self.view addSubview:indicatorView]; 6 7 // 将风火轮启动 8 [indicatorView startAnimating];
Gif动画
1 // 创建显示图片的ImageView 2 UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, 400, 200)]; 3 [self.view addSubview:imgView]; 4 // 创建一个存储图片的数组 5 NSMutableArray *saveImageArray = [NSMutableArray array]; 6 for (int i = 1; i < 12; i++) { 7 NSString *imageName = [NSString stringWithFormat:@"2288dce40fe3c6723acdba8bd7177c73-%d(被拖移).tiff", i]; 8 UIImage *image = [UIImage imageNamed:imageName]; 9 [saveImageArray addObject:image]; 10 } 11 // 设置GIF图片组 12 imgView.animationImages = saveImageArray; 13 // 设置播放速率 14 imgView.animationDuration = 1.0f; 15 // 设置播放次数(-1是无限播放) 16 imgView.animationRepeatCount = -1; 17 // 开启GIF动画 18 [imgView startAnimating];