汤姆猫(动画)

UIImageView *imageView = [[UIImageView alloc] init];

imageView.frame = CGRectMake(0, 0, 320, 480);

//1.准备电影胶卷

NSMutableArray *films = [[NSMutableArray alloc] init];

for (NSInteger i = 0; i <= 80; ++i)

{

//cat_drink0000.jpg

NSString *name = [NSString stringWithFormat:@"cat_drink%04d.jpg", i];

UIImage *image = [UIImage imageNamed:name];

[films addObject:image];

}

imageView.image = films[0];

//2.将胶卷装到imageView中

imageView.animationImages = films;

//3.设置播放总时间

imageView.animationDuration = 5.f;

//4.设置重复次数,0为无限循环

imageView.animationRepeatCount = 0;

//5.开始播放

[imageView startAnimating];

//6.结束播放

//[imageView stopAnimating];

//7.判断当前播放状态

//[imageView isAnimating];

UITapGestureRecognizer(手势三部曲)

//1、创建手势

UITapGestureRecognizer *r1 = [[UITapGestureRecognizer alloc] init];

//2、手势触发事件

[r1 addTarget:self action:<#(SEL)#>];

//3、把手势应用在哪

[self.window addGestureRecognizer:r1];

启动动画

[UIView animateWithDuration:<#(NSTimeInterval)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

你可能感兴趣的:(汤姆猫(动画))