IOS基础控件 UIImageView swift3.1

//
//  ViewController.swift
//  UIImageView
//
//  Created by hong wang on 2017/6/2.
//  Copyright © 2017年 appio. All rights reserved.
//


import UIKit


class ViewController: UIViewController {


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        //ImageView Demo1
        let imgView1:UIImageView = UIImageView(frame: CGRect(x: 0, y: 50, width: 320, height: 132) )
        //设置图片
        imgView1.image = UIImage(named: "1.png")
        //添加到当前视图
        self.view.addSubview(imgView1)
        
        //ImageView Demo2
        let imgView2:UIImageView = UIImageView(frame: CGRect(x: 0, y: 200, width: 320, height: 132) )
        imgView2.image = UIImage(named: "1.png")
        //设置高亮图片
        imgView2.highlightedImage = UIImage(named: "14.png")
        //设置高亮
        imgView2.isHighlighted = true
        self.view.addSubview(imgView2)
        
        //ImageView Demo3
        let imgView3:UIImageView = UIImageView(frame: CGRect(x: 0, y: 350, width: 320, height: 132) )
        imgView3.image = UIImage(named: "1.png")
        imgView3.highlightedImage = UIImage(named: "14.png")
        //imgView3.isHighlighted = true


        self.view.addSubview(imgView3)
        
        //创建Image数组
        var ImgArr:Array<UIImage> = Array()
        ImgArr.append(UIImage(named: "1.png")!)
        ImgArr.append(UIImage(named: "2.png")!)
        ImgArr.append(UIImage(named: "3.png")!)
        ImgArr.append(UIImage(named: "4.png")!)
        ImgArr.append(UIImage(named: "5.png")!)
        ImgArr.append(UIImage(named: "6.png")!)
        ImgArr.append(UIImage(named: "7.png")!)
        ImgArr.append(UIImage(named: "8.png")!)
        ImgArr.append(UIImage(named: "9.png")!)
        ImgArr.append(UIImage(named: "10.png")!)
        ImgArr.append(UIImage(named: "11.png")!)
        ImgArr.append(UIImage(named: "12.png")!)
        ImgArr.append(UIImage(named: "13.png")!)
        ImgArr.append(UIImage(named: "14.png")!)
        //添加数据到ImageView
        imgView3.animationImages = ImgArr as [UIImage]
        //播放次数
        imgView3.animationRepeatCount = 0
        //播放一组时间
        imgView3.animationDuration = 1.5
        //开始播放
        imgView3.startAnimating()
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值