zoukankan      html  css  js  c++  java
  • iOS学习

    //
    //  YJViewController.m
    //  04-汤姆猫的理解
    //
    //  Created by JACKY-MAC on 15-5-31.
    //  Copyright (c) 2015年 www.train.com. All rights reserved.
    //
    
    #import "YJViewController.h"
    
    @interface YJViewController ()
    @property (weak, nonatomic) IBOutlet UIImageView *tom;
    
    @end
    
    @implementation YJViewController
    - (void)tomAnimationWithName:(NSString *) name  andCount:(NSInteger)count
    {
        if ([self.tom isAnimating]) return;
            
        
        // 动画图片的数
        NSMutableArray *arrayM = [NSMutableArray array];
        
        // 添加动画播放的图片
        
        for (int i=0; i<count; i++) {
            
              // 图像名称
            NSString *imageName = [NSString stringWithFormat:@"%@_%02d.jpg",name,i];
            
            NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
            UIImage *image = [UIImage imageWithContentsOfFile:path];
            
            [arrayM addObject:image];
        }
        
           // 设置动画数组
        self.tom.animationImages = arrayM;
        
            // 重复1次
        self.tom.animationRepeatCount = 1;
        
            // 动画时长
        self.tom.animationDuration = self.tom.animationImages.count * 0.075;
        
         // 开始动画
        [self.tom startAnimating];
        
        
        // 动画"结束"之后,清理动画数组
        [self.tom performSelector:@selector(setAnimationImages:) withObject:nil
                       afterDelay:self.tom.animationDuration];
        
    }
    /*
    - (IBAction)tomAction:(UIButton *)sender
    {
            // currentTitle 可以取出按钮当前的标题文字
        [self tomAnimationWithName:sender.currentTitle andCount:sender.tag];
    }
    
    */
    - (IBAction)knockout
    {
        [self tomAnimationWithName:@"knockout" andCount:81];
    }
    
    
    - (IBAction)eat
    {
        [self tomAnimationWithName:@"eat" andCount:40];
    }
    
    
    - (IBAction)cymbal
    {
        [self tomAnimationWithName:@"cymbal" andCount:12];
    }
    
    - (IBAction)drink
    {
        [self tomAnimationWithName:@"drink" andCount:80];
    }
    
    - (IBAction)fart
    {
        [self tomAnimationWithName:@"fart" andCount:27];
    }
    
    -(IBAction)pie
    {
        [self tomAnimationWithName:@"pie" andCount:23];
    }
    
    - (IBAction)scratch
    {
        [self tomAnimationWithName:@"scratch" andCount:55];
    }
    
    
    - (IBAction)stomach
    {
        [self tomAnimationWithName:@"stomach" andCount:34];
    }
    
    - (IBAction)footLeft
    {
        [self tomAnimationWithName:@"footLeft" andCount:30];
    }
    
    - (IBAction)footRight
    {
        [self tomAnimationWithName:@"footRight" andCount:30];
    }
    @end

  • 相关阅读:
    生活中的大数据 hadoop
    IOS设计模式学习(11)中介者
    Java 编程的动态性,第3部分: 应用反射--转载
    Java编程 的动态性,第 2部分: 引入反射--转载
    Java 编程的动态性 第1 部分: 类和类装入--转载
    斐波那契数列(fabnacci)java实现
    Chrome调试大全--转载
    jboss7 加载module过程
    UML解惑:图说UML中的六大关系--转
    jboss学习
  • 原文地址:https://www.cnblogs.com/yejian/p/4761581.html
Copyright © 2011-2022 走看看