小波说雨燕 第三季 构建 swift UI 之 UI组件集-视图集(五)Image View视图 学习笔记
2016-03-11 00:00
776 查看
留下两个问题:1、后面涉及到的异常不知道原因。2、动态图片到了程序里面就不动了。
![](http://static.oschina.net/uploads/img/201603/11172940_wJli.png)
![](http://static.oschina.net/uploads/img/201603/11172941_g2Kh.png)
![](http://static.oschina.net/uploads/img/201603/11172941_thoC.png)
![](http://static.oschina.net/uploads/img/201603/11172941_DWOy.png)
![](http://static.oschina.net/uploads/img/201603/11172941_I6Hz.png)
![](http://static.oschina.net/uploads/img/201603/11172941_78a6.png)
![](http://static.oschina.net/uploads/img/201603/11172942_wq2s.png)
然后:
![](http://static.oschina.net/uploads/img/201603/11172942_n1Hx.png)
![](http://static.oschina.net/uploads/img/201603/11172942_7TzM.png)
上面是有问题的,下面是没有问题的了。
![](http://static.oschina.net/uploads/img/201603/11172942_acXP.png)
代码(另外简单写的代码,纠正了那个错误):
根据小波老师改进后的方法(如果有100张,如果一张一张添加创建对象,就不好了):
![](http://static.oschina.net/uploads/img/201603/11172940_wJli.png)
![](http://static.oschina.net/uploads/img/201603/11172941_g2Kh.png)
![](http://static.oschina.net/uploads/img/201603/11172941_thoC.png)
![](http://static.oschina.net/uploads/img/201603/11172941_DWOy.png)
![](http://static.oschina.net/uploads/img/201603/11172941_I6Hz.png)
![](http://static.oschina.net/uploads/img/201603/11172941_78a6.png)
![](http://static.oschina.net/uploads/img/201603/11172942_wq2s.png)
然后:
![](http://static.oschina.net/uploads/img/201603/11172942_n1Hx.png)
![](http://static.oschina.net/uploads/img/201603/11172942_7TzM.png)
上面是有问题的,下面是没有问题的了。
![](http://static.oschina.net/uploads/img/201603/11172942_acXP.png)
代码(另外简单写的代码,纠正了那个错误):
1 import UIKit 2 3 class ViewController: UIViewController{ 4 5 @IBOutlet weak var imageView: UIImageView! 6 @IBAction func button(sender: UIButton) { 7 imageView.animationImages = [UIImage(named: "p1")!,UIImage(named: "p2")!,UIImage(named: "p3")!,UIImage(named: "p4")!,UIImage(named: "p5")!] 8 imageView.contentMode = .ScaleAspectFit 9 imageView.animationDuration = 10 10 imageView.startAnimating() 11 12 } 13 override func viewDidLoad() { 14 super.viewDidLoad() 15 16 } 17 18 override func didReceiveMemoryWarning() { 19 super.didReceiveMemoryWarning() 20 } 21 }
根据小波老师改进后的方法(如果有100张,如果一张一张添加创建对象,就不好了):
1 import UIKit 2 3 class ViewController: UIViewController{ 4 5 @IBOutlet weak var imageView: UIImageView! 6 @IBAction func button(sender: UIButton) { 7 // imageView.animationImages = [UIImage(named: "p1")!,UIImage(named: "p2")!,UIImage(named: "p3")!,UIImage(named: "p4")!,UIImage(named: "p5")!] 8 imageView.animationImages = (1...5).map{ 9 UIImage(named: "p\($0)")! 10 } 11 imageView.contentMode = .ScaleAspectFit 12 imageView.animationDuration = 10 13 imageView.startAnimating() 14 15 } 16 override func viewDidLoad() { 17 super.viewDidLoad() 18 19 } 20 21 override func didReceiveMemoryWarning() { 22 super.didReceiveMemoryWarning() 23 } 24 }
相关文章推荐
- Swift 中的函数(上)
- Swift Standard Library: Documented and undocumented built-in functions in the Swift standard libr...
- Swift面向对象基础(上)——Swift中的类和结构体(上)
- Welcome-to-Swift
- The Swift Programming Language 中英文双语版
- Swift3.0中代理的使用方法
- swift官方推荐翻译文档之集合类型
- 1.swift 的架构
- Swift开发笔记之UIButton基本用法
- swift的代理
- Swift 基础学习(构造方法初印象)
- Swift 2.0 异常处理
- core image几个滤镜例子 oc版本和swift版本
- Swift语言iOS8的蓝牙Bluetooth解析
- Swift 基础学习(继承)
- new in swift
- Swift之?和!
- swift 取得一个字符的ascii值或者unicode值
- swift:iOS模拟器键盘设置(弹出,中文键盘,隐藏)
- swift 学习笔记5 懒加载