zoukankan      html  css  js  c++  java
  • 汤姆猫(。。。。)

    1:如何使用UIImageView播放动画

    2:从bundle中加载图片的两种方式

    3怎么样延迟执行某个方法

    项目的源码以及素材

    链接: http://pan.baidu.com/s/1hq4fWrE 密码: xqkw

    主要的修改有:使用switch case来进行点击事件的区分。

    核心代码是:

    -(void)actionWithFilename:(NSString *)name andImgCount:(NSInteger)count{

        NSMutableArray *imgArr = [NSMutableArray array];

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

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

            NSString *path = [[NSBundle mainBundle]pathForResource:imgName ofType:nil];

            UIImage *image = [UIImage imageWithContentsOfFile:path];//系统不缓存图片

    //        UIImage *image = [UIImage imageNamed:imgName];//如果使用这种方法来加载bundle中的图片的时候,系统会自动缓存这些图片

            

            [imgArr addObject:image];

        }

        

        self.backIV.animationImages = imgArr;//注意这里的数组里存放的是image而不是字符串

        [self.backIV setAnimationImages:imgArr];

        self.backIV.animationDuration = count * .1;

        self.backIV.animationRepeatCount = 1;

        [self.backIV startAnimating];

        CGFloat time = self.backIV.animationRepeatCount * self.backIV.animationDuration;

    //    延迟执行某个方法

    //    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    //        self.backIV.animationImages = nil;//清除动画需要的图片

    //    });

        

        //就是将nil赋值给了AnimationImages 即[self.backIV setAnimationImages:nil];

        [self.backIV performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:time];

    }

  • 相关阅读:
    Java对象序列化/反序列化的注意事项
    初尝Java序列化/反序列化对象
    Java的byte数组
    在C#或者SWT上跨进程访问SWT控件的问题
    Enum实现单例模式
    看个泛型的例子
    构造器优化需要多个构造器的类(建造者模式)
    线程间操作无效: 从不是创建控件的线程访问它.
    SWT中的多线程(Invalid thread access)
    读书笔记 --腾讯传
  • 原文地址:https://www.cnblogs.com/mudy/p/4831587.html
Copyright © 2011-2022 走看看