美文网首页
ios学习第3天

ios学习第3天

作者: 蹦哒_ | 来源:发表于2016-07-12 22:59 被阅读0次

    //

    //ViewController.m

    //汤姆猫

    //

    //Created by lanou on 16/7/12.

    //Copyright © 2016年pingguo. All rights reserved.

    //

    #import"ViewController.h"

    @interfaceViewController()

    @property(weak,nonatomic)IBOutletUIImageView*tomCatView;

    @end

    @implementationViewController

    - (void)viewDidLoad {

    [superviewDidLoad];

    //UIImageView*imageView=[UIImageViewnew];

    //序列成动画要播放的图片数组

    //imageView.animationImages

    //动画时长

    //imageView.animationDuration

    //动画重复次数

    //imageView.animationRepeatCount

    //开始动画

    //[imageView startAnimating];

    //结束动画

    //[imageView stopAnimating];

    //是否正在执行动画

    //[imageViewisAnimating];

    }

    - (IBAction)eatBirdAction:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"eat"withCount:40];

    /*

    //创建可变数组images,负责存放要播放的图片数组

    NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<40; i++) {

    //根据i来加载图片,然后添加到可变数组images里面

    NSString*imageName=[NSStringstringWithFormat:@"eat_%02ld.jpg",i];

    //根据格式化的图片名加载图片image

    UIImage*image=[UIImageimageNamed:imageName];

    //将图片image添加到数组images中

    [imagesaddObject:image];

    }

    //设置动画图片数组

    self.tomCatView.animationImages=images;

    //设置动画时长

    self.tomCatView.animationDuration=40*0.075;

    //设置动画重复次数

    self.tomCatView.animationRepeatCount=1;

    //开始动画

    [self.tomCatView startAnimating];*/

    }

    -(void)setTomCatAnimationWithName:

    (NSString*)namewithCount:(NSInteger)count

    {

    //判断该动画是否正在执行

    if([self.tomCatViewisAnimating]) {

    return;

    }

    //创建可变数组images,负责存放要播放的图片数组

    NSMutableArray*images=[NSMutableArrayarray];

    for(NSIntegeri=0; i

    //根据i来加载图片,然后添加到可变数组images里面

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

    //根据格式化的图片名加载图片image

    UIImage*image=[UIImageimageNamed:imageName];

    //将图片image添加到数组images中

    [imagesaddObject:image];

    }

    //设置动画图片数组

    self.tomCatView.animationImages=images;

    //设置动画时长

    self.tomCatView.animationDuration=count*0.075;

    //设置动画重复次数

    self.tomCatView.animationRepeatCount=1;

    //开始动画

    [self.tomCatViewstartAnimating];

    }

    - (IBAction)drink:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"drink"withCount:81];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<81; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"drink_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=80*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    - (IBAction)pie:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"pie"withCount:24];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<24; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"pie_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=24*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    - (IBAction)scratch:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"scratch"withCount:56];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<56; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"scratch_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=56*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    - (IBAction)fart:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"fart"withCount:28];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<28; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"fart_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=28*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    - (IBAction)cymbal:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"cymbal"withCount:13];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<13; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"cymbal_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=13*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    //头部按钮动画

    - (IBAction)knockout:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"knockout"withCount:81];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<81; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"knockout_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=81*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    //尾巴按钮动画

    - (IBAction)angry:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"angry"withCount:26];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<26; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"angry_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=26*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    //制作肚子按钮动画

    - (IBAction)stomach:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"stomach"withCount:34];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<34; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"stomach_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=34*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    //制作左脚按钮动画

    - (IBAction)footleft:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"footLeft"withCount:30];

    /*NSMutableArray*images=[NSMutableArrayarray];

    for (NSIntegeri=0; i<30; i++) {

    NSString*imageName=[NSStringstringWithFormat:@"footLeft_%02ld.jpg",i];

    UIImage*image=[UIImageimageNamed:imageName];

    [imagesaddObject:image];

    }

    self.tomCatView.animationImages=images;

    self.tomCatView.animationDuration=30*0.075;

    self.tomCatView.animationRepeatCount=1;

    [self.tomCatView startAnimating];*/

    }

    //制作右脚按钮动画

    - (IBAction)footright:(UIButton*)sender {

    [selfsetTomCatAnimationWithName:@"footRight"withCount:30];

    }

    - (void)didReceiveMemoryWarning{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be

    recreated.

    }

    @end

    相关文章

      网友评论

          本文标题:ios学习第3天

          本文链接:https://www.haomeiwen.com/subject/uqssjttx.html