zoukankan      html  css  js  c++  java
  • 【iOS系列】-UIImageView帧动画相关属性介绍

    UIImageView帧动画相关属性介绍

    1:相关属性:

    //An array of UIImage objects to use for an animation.存放UIImage对象,会按顺序显示里面的图片
    @property(nonatomic,copy) NSArray *animationImages; 
    	
    //帧动画的持续时间
    @property(nonatomic) NSTimeInterval animationDuration;
    	
    //帧动画的执行次数(默认是无限循环)
    @property(nonatomic) NSInteger animationRepeatCount; 
    
    //开始执行帧动画
    - (void)startAnimating;
    
    //停止执行帧动画
    - (void)stopAnimating;
    
    //是否正在执行帧动画
    - (BOOL)isAnimating;
    

    2:关于缓存

    由于UIImageview是一下子把全部图片全部加载,所以当对于缓存一定要进行管理否则,程序性能是个大问题

    2.1:我们从UIImage入手,image加载有两种方式,api中相关介绍如下

    //This method does not cache the image object.
    [UIImage imageWithContentsOfFile:name]
    
    //This method looks in the system caches for an image object with the specified name and returns that object if it exists.
    [UIImage imageNamed:name]
    

    一般我们用的就是imageNamed,imageNamed中加载图片后有缓存,下次加载的时候,缓存中有就直接区,这对于我们平时使用很是便利,但是播放动画的时候,动辄几十张甚至几百张图片来说,我们就选择imageWithContentsOfFile这种方式

    2.2:动画播放完毕后,要手动清理内存

    CGFloat delay = self.tom.animationDuration + 1.0;
    [self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:delay];
  • 相关阅读:
    HDU 2159 FATE【二维多重背包】
    HDU 1203 I NEED A OFFER!【01背包】
    HDU 1171 Big Event in HDU【多重背包】
    HDU 2844 Coins【多重背包】
    POJ 1014 Dividing【多重背包+二进制优化】
    HDU 2191 悼念512【多重背包+二进制优化】
    HDU 2602 Bone Collector【01背包】
    POJ 2060 Taxi Cab Scheme【最小路径覆盖】
    0828
    BZOJ2783: [JLOI2012]树
  • 原文地址:https://www.cnblogs.com/fengtengfei/p/4417140.html
Copyright © 2011-2022 走看看