Skip to content

Latest commit

 

History

History
19 lines (11 loc) · 299 Bytes

09.md

File metadata and controls

19 lines (11 loc) · 299 Bytes

懒加载

swiftlazy var demoView: UIView = {

 let v = UIView(frame: CGRectMake(10, 10, 100, 100)) v.backgroundColor = UIColor.redColor()

 return v}()
  • 格式:
lazy var 变量: 类型 = { 创建变量代码 }()
  • 懒加载的写法本质上是定义并执行一个闭包