self.imageView = [[UIImageView alloc] initWithFrame:(CGRectMake(0, 0, 100, 100))];
self.imageView.image = [UIImage imageNamed:@"circle"];
[self.view addSubview:self.imageView];
[self startAnimation];
- (void)startAnimation
{
// UIViewAnimationOptionCurveLinear匀速执行(默认就是它)
[UIView animateWithDuration:0.01 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
self.imageView.transform = CGAffineTransformMakeRotation(i * M_PI / 180.f);
} completion:^(BOOL finished) {
i += 7; [self startAnimation];
}];
}
把GIF图片里的每一帧复制出来,mac上直接全选,拖出来就行。拖出来是TIFF格式,没关系,一样用。
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
NSMutableArray *image_arr = [NSMutableArray array];
for (int i = 1; i < 50; i++) {
NSString *name = [NSString stringWithFormat:@"textGIF%d.tiff", i];
UIImage *image = [[UIImage alloc] init];
image = [UIImage imageNamed:name];
[image_arr addObject:image];
NSLog(@"image:%@", image);
}
NSLog(@"%@", self.imageView);
self.imageView.animationImages = image_arr;
self.imageView.animationDuration = 4;
self.imageView.animationRepeatCount = 100;
[self.imageView startAnimating];
[self.view addSubview:self.imageView];