码迷,mamicode.com
首页 > 其他好文 > 详细

15.小项目:汤姆猫 版本1.0

时间:2015-08-03 00:47:09      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

-------------  ViewController.m  -------------

#import "ViewController.h"


@interface ViewController ()

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

- (IBAction)drink;

- (IBAction)konckOut;

- (IBAction)footLeft;

@end


@implementation ViewController

- (IBAction)drink

{

    if(self.imageView.isAnimating)

    {

        return;

    }

    NSMutableArray *images = [NSMutableArray array];

    for (int i = 0; i < 81; i++)

    {

        NSString *imageName = [NSString stringWithFormat:@"drink_%02d", i];

        UIImage *image = [UIImage imageNamed:imageName];

        [images addObject:image];

    }

    self.imageView.animationImages = images;

    self.imageView.animationDuration = 0.05 * 81;

    self.imageView.animationRepeatCount = 1;

    [self.imageView startAnimating];

}


- (IBAction)konckOut

{

    if(self.imageView.isAnimating)

    {

        return;

    }

    NSMutableArray *images = [NSMutableArray array];

    for (int i = 0; i < 81; i++)

    {

        NSString *imageName = [NSString stringWithFormat:@"knockout_%02d", i];

        UIImage *image = [UIImage imageNamed:imageName];

        [images addObject:image];

    }

    self.imageView.animationImages = images;

    self.imageView.animationDuration = 0.05 * 81;

    self.imageView.animationRepeatCount = 1;

    [self.imageView startAnimating];

}


- (IBAction)footLeft

{

    if(self.imageView.isAnimating)

    {

        return;

    }

    NSMutableArray *images = [NSMutableArray array];

    for (int i = 0; i < 30; i++)

    {

        NSString *imageName = [NSString stringWithFormat:@"footLeft_%02d", i];

        UIImage *image = [UIImage imageNamed:imageName];

        [images addObject:image];

    }

    self.imageView.animationImages = images;

    self.imageView.animationDuration = 0.05 * 30;

    self.imageView.animationRepeatCount = 1;

    [self.imageView startAnimating];

}

@end

 

15.小项目:汤姆猫 版本1.0

标签:

原文地址:http://www.cnblogs.com/lixiang2015/p/4696958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!