在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
// 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. } } |
请发表评论