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];
    }
  • 相关阅读:
    MySQL 幻读详解
    vue-layer 弹窗z-index问题
    vue-cli 路径不变 改变参数 显示不同组件
    mysql ---- limit使用方式
    mysql ---- 官网的测试数据库
    2020年度总结和2021年目标
    校招(春招实习 + 秋招)总结感想
    Centos8和7的区别(参照redhat)
    centos8 网卡命令(centos7也可用)
    排查linux系统是否被入侵
  • 原文地址:https://www.cnblogs.com/feiyu-mdm/p/5568551.html
Copyright © 2011-2022 走看看