zoukankan      html  css  js  c++  java
  • iOS开发-Tom猫

    //

    //  ViewController.m

    //  20-tom

    //

    //  Created by hongqiangli on 2017/8/1.

    //  Copyright © 李洪强. All rights reserved.

    //

     

    #import "ViewController.h"

     

    @interface ViewController ()

    - (IBAction)drink;

    - (IBAction)knock;

    @property (weak, nonatomic) IBOutlet UIImageView *tomImageView;

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        

    }

     

     

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

     

     

    - (IBAction)drink {

        

        

        [self runAnimationWithCount:81 andName:@"drink"];

        

    }

     

    - (IBAction)knock {

        [self runAnimationWithCount:81 andName:@"knockout"];

    }

     

    - (void)runAnimationWithCount:(int)count andName:(NSString *)name{

        //判断动画是否执行

        if(_tomImageView.isAnimating){

            return;

        }

        //拿到图片

        NSMutableArray *imageMarr = [NSMutableArray array];

        for(int i = 0; i < count; i++){

            NSString *imageName = [NSString stringWithFormat:@"%@_%02d.jpg",name,i];

            NSString *imagePath = [[NSBundle mainBundle]pathForResource:imageName ofType:nil];

            UIImage *image = [UIImage imageWithContentsOfFile:imagePath];

            [imageMarr addObject:image];

        }

        

        //2.告诉imageView执行的时间

    //    2.1动画执行的时间

        //每播放一张图片的时间为0.05

        CGFloat delat = 0.05;

        _tomImageView.animationDuration = delat *imageMarr.count;

        //2.3动画执行的次数

        _tomImageView.animationRepeatCount = 1;

        _tomImageView.animationImages = imageMarr;

        //3 开启动画

        [_tomImageView startAnimating];

        //动画执行完毕后,清空图片对象animationImages

        [self performSelector:@selector(clearCache) withObject:nil afterDelay:imageMarr.count *delat];

        

        

    }

     

    - (void)clearCache{

        

        _tomImageView.animationImages =nil;

        [_tomImageView setAnimationImages:nil];

    }

     

    @end

     

     

     

     

     

     

     

  • 相关阅读:
    多维DP UVA 11552 Fewest Flop
    思维/构造 HDOJ 5353 Average
    map Codeforces Round #Pi (Div. 2) C. Geometric Progression
    构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
    贪心+优先队列 HDOJ 5360 Hiking
    贪心 HDOJ 5355 Cake
    LIS UVA 10534 Wavio Sequence
    又见斐波那契~矩阵快速幂入门题
    Big Christmas Tree(poj-3013)最短路
    poj 2449 Remmarguts' Date 第k短路 (最短路变形)
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/7273471.html
Copyright © 2011-2022 走看看