zoukankan      html  css  js  c++  java
  • IOS 动画播放案例

    #import "ViewController.h"
    
    @interface ViewController ()
    @property (weak,nonatomic) IBOutlet UIImageView *imageView;
    - (IBAction)head;
    @end
    @implementation ViewController
    
    - (IBAction)head {
       // 图片张数, 图片名称
        [self SetDataInfo:81 PicName:@"knockout"];
    }
    
    -(void) SetDataInfo:(int)count PicName:(NSString*)PicName{
        //当imageView图片框正在执行动画,则return
        if  (self.imageView.isAnimating)
        {
            return;
        }
        //声明数组
        NSMutableArray * arrayM = [NSMutableArray array];
        //循环取得图片名称,并添加到数组中
        for(int i  = 0; i < count; i++)
        {
            //拼接图片名称
            NSString *imgName =[NSString stringWithFormat:@"%@_%02d.jpg",PicName,i];
            //获取图片完整路径,不使用缓存
            //另一种方试调用imageNamed:这种方式是图片保存到内存当中,占用内存过大
            NSString *path =[[NSBundle mainBundle] pathForResource:imgName ofType:nil];
            //根据图片路径取到图片
            UIImage* imgCat = [UIImage imageWithContentsOfFile:path];
            //添加到数组
            [arrayM addObject:imgCat];
        }
         //1.设置UIImageView (图片框) 的animationImages 属性,这个属性中包含所有要执行的动画图片
        self.imageView.animationImages =arrayM;
         //2.设置动画持续时间
        self.imageView.animationDuration =self.imageView.animationImages.count * 0.1;
         //3.设置动画是否重复播放
        self.imageView.animationRepeatCount = 1;
         //4.开启动画
        [self.imageView startAnimating];
        //设置图片框在调用setAnimationImages:nil 方法的时候延迟执行
        [self.imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageView.animationImages.count *0.1];
  • 相关阅读:
    检测c/c++中内存泄露
    在一个集合S中寻找最大的C使A+B=C且A,B,C均在集合当中
    《为学》
    U盘windows无法格式化的解决办法
    java.lang.AbstractMethodError: oracle.jdbc.driver...解决方法
    sqlplus连接远程Oracle
    oracle字符集导致的乱码问题
    大端与小端存储模式详解
    《劝学》原文
    《报任安书》司马迁
  • 原文地址:https://www.cnblogs.com/zzgt/p/4739500.html
Copyright © 2011-2022 走看看