zoukankan      html  css  js  c++  java
  • imageView的使用

    转自:http://www.runoob.com/ios/att-ios-ui-imageview.html

    图像视图用于显示单个图像或动画序列的图像。

    重要的属性

    • image
    • highlightedImage
    • userInteractionEnabled
    • animationImages
    • animationRepeatCount

    重要的方法

    - (id)initWithImage:(UIImage *)image
    - (id)initWithImage:(UIImage *)image highlightedImage:
      (UIImage *)highlightedImage
    - (void)startAnimating
    - (void)stopAnimating

    添加自定义方法 addImageView

    -(void)addImageView{
        UIImageView *imgview = [[UIImageView alloc]
        initWithFrame:CGRectMake(10, 10, 300, 400)];
        [imgview setImage:[UIImage imageNamed:@"AppleUSA1.jpg"]];
        [imgview setContentMode:UIViewContentModeScaleAspectFit];
        [self.view addSubview:imgview];
    }

    添加另一个自定义方法 addImageViewWithAnimation

    这种方法解释了如何对imageView 中的图像进行动画处理

    -(void)addImageViewWithAnimation{
        UIImageView *imgview = [[UIImageView alloc]
        initWithFrame:CGRectMake(10, 10, 300, 400)];
        // set an animation
        imgview.animationImages = [NSArray arrayWithObjects:
        [UIImage imageNamed:@"AppleUSA1.jpg"],
        [UIImage imageNamed:@"AppleUSA2.jpg"], nil];
        imgview.animationDuration = 4.0;
        imgview.contentMode = UIViewContentModeCenter;
        [imgview startAnimating];
        [self.view addSubview:imgview];
    }

    注意: 我们必须添加命名为"AppleUSA1.jpg"和"AppleUSA2.jpg"到我们的项目,可以通过将图像拖到我们导航区域,其中列出了我们的项目文件所做的图像。

    在 ViewController.m 中更新 viewDidLoad,如下所示

    (void)viewDidLoad
    {
       [super viewDidLoad];
       [self addImageView];
    }
  • 相关阅读:
    Console命令,让js调试更简单
    Java练习 SDUT-2192_救基友记2
    Java练习 SDUT-2246_时间日期格式转换
    SDUT-3362_村村通公路
    SDUT-2139_从起始点到目标点的最短步数(BFS)
    SDUT-3361_迷宫探索
    SDUT-2138_判断可达性
    SDUT-2107_图的深度遍历
    SDUT-2124_基于邻接矩阵的广度优先搜索遍历
    Java练习 SDUT-2787_加密术
  • 原文地址:https://www.cnblogs.com/feiyu-mdm/p/5568551.html
Copyright © 2011-2022 走看看