zoukankan      html  css  js  c++  java
  • UIImageView

    UIImageView相当于一个相框,用来显示图片,里边可以是一张图片,也可以是一组图片。

    RootView.m

    - (void)p_setupView{

        self.backgroundColor = [UIColor yellowColor];

       

        self.imv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];

        self.imv.backgroundColor = [UIColor whiteColor];

       

     

       

        [self addSubview:_imv];

       

     

    RootViewController.m

     

    - (void)viewDidLoad {

        [super viewDidLoad];

       

        // 准备一个image的数组

        NSMutableArray *imArr = [NSMutableArray array];

        // 循环生成image放入数组

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

            NSString *nameStr = [NSString stringWithFormat:@"%d.tiff",i];

            [imArr addObject:[UIImage imageNamed:nameStr]];

        }

        // 执行一组所用时间

        self.rv.imv.animationDuration = 1;   

        // 循环5此

     

        self.rv.imv.animationRepeatCount = 5;   

        // 将image数组 赋值给animationImages

        self.rv.imv.animationImages = imArr;   

        // 开始动画

        [self.rv.imv startAnimating ];   

        // 结束动画,就什么都不显示了。

    //    [self.rv.imv stopAnimating];

       

    }

     

     

    1、初始化方法:initWithFrame与普通视图差不多

     

    2、animationImages,设置一组图片(是一个数组)

     

    3、animationDuration,设置执行一组图片用多长时间

     

    4、animationRepeatCount,执行多少次这组图片

     

    5、startAnimating,开始动画

     

    6、stopAnimating,停止动画(停止动画的意思不是让图片停止在某个状态,而是直接不再显示图片)

     

  • 相关阅读:
    poj 2155 Matrix
    iOS之Prefix.pch
    多用派发队列,少用同步锁
    SenTestingKit.framework的报错!
    xcode4的环境变量,Build Settings参数,workspace及联编设置
    xcode4中build Settings常见参数解析
    XCode环境变量及路径设置
    Xcode添加静态库以及编译选项配置常见问题
    基于第三方微信授权登录的iOS代码分析
    理解iOS 8中的Self Sizing Cells和Dynamic Type
  • 原文地址:https://www.cnblogs.com/Coder-GT/p/4876085.html
Copyright © 2011-2022 走看看