Swift - UITableView展开缩放动画

效果

源码

https://github.com/YouXianMing/Swift-Animations

//
// HeaderViewTapAnimationController.swift
// Swift-Animations
//
// Created by YouXianMing on 16/8/9.
// Copyright © 2016年 YouXianMing. All rights reserved.
// import UIKit class HeaderViewTapAnimationController: NormalTitleViewController, UITableViewDelegate, UITableViewDataSource { private var classes : [ClassModel]!
private var tableView : UITableView!
private var sectionFirstLoad : Bool!
private weak var tmpHeadView : ClassHeaderView! override func setup() { super.setup() sectionFirstLoad = false // TableView.
tableView = UITableView(frame: (contentView?.bounds)!)
tableView.dataSource = self
tableView.delegate = self
tableView.rowHeight =
tableView.sectionHeaderHeight =
tableView.separatorStyle = .None
contentView?.addSubview(tableView!) // Register.
ClassHeaderView.registerToTableView(tableView)
StudentInfoCell.registerToTableView(tableView) // Data source.
let Aitna = ClassModel(className: "Aitna")
Aitna.expend = false
Aitna.students?.append(StudentModel(name: "Y.X.M.", age: ))
Aitna.students?.append(StudentModel(name: "Leif", age: ))
Aitna.students?.append(StudentModel(name: "Lennon", age: ))
Aitna.students?.append(StudentModel(name: "Jerome", age: ))
Aitna.students?.append(StudentModel(name: "Isidore", age: )) let Melete = ClassModel(className: "Melete")
Melete.expend = false
Melete.students?.append(StudentModel(name: "Merle", age: ))
Melete.students?.append(StudentModel(name: "Paddy", age: ))
Melete.students?.append(StudentModel(name: "Perry", age: ))
Melete.students?.append(StudentModel(name: "Philip", age: )) let Aoede = ClassModel(className: "Aoede")
Aoede.expend = false
Aoede.students?.append(StudentModel(name: "Verne", age: ))
Aoede.students?.append(StudentModel(name: "Vincent", age: ))
Aoede.students?.append(StudentModel(name: "Walter", age: ))
Aoede.students?.append(StudentModel(name: "Zachary", age: )) let Dione = ClassModel(className: "Dione")
Dione.expend = false
Dione.students?.append(StudentModel(name: "Timothy", age: ))
Dione.students?.append(StudentModel(name: "Roderick", age: ))
Dione.students?.append(StudentModel(name: "Quentin", age: ))
Dione.students?.append(StudentModel(name: "Paddy", age: )) let Adanos = ClassModel(className: "Adanos")
Adanos.expend = false
Adanos.students?.append(StudentModel(name: "Mortimer", age: ))
Adanos.students?.append(StudentModel(name: "Michael", age: ))
Adanos.students?.append(StudentModel(name: "Kevin", age: ))
Adanos.students?.append(StudentModel(name: "Jeremy", age: )) classes = [ClassModel]()
classes.append(Aitna)
classes.append(Melete)
classes.append(Aoede)
classes.append(Dione)
classes.append(Adanos) // Expend animations.
GCDQueue.executeInMainQueue({ self.sectionFirstLoad = true
self.tableView.insertSections(NSIndexSet(indexesInRange: NSMakeRange(, self.classes.count)), withRowAnimation: .Fade) GCDQueue.executeInMainQueue({ self.tmpHeadView.buttonEvent() }, afterDelaySeconds: 0.4)
}, afterDelaySeconds: 0.3)
} // MARK: UITableView's delegate & dataSource. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { let classModel = classes[section]
if classModel.expend == true { return (classModel.students?.count)! } else { return
}
} func numberOfSectionsInTableView(tableView: UITableView) -> Int { if sectionFirstLoad == false { return } else { return classes.count
}
} func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let classModel = classes[indexPath.section]
let customCell = tableView.dequeueReusableCellWithIdentifier("StudentInfoCell") as! CustomCell
customCell.data = classModel.students![indexPath.row]
customCell.indexPath = indexPath
customCell.loadContent() return customCell
} func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { tableView.selectedEventWithIndexPath(indexPath)
} func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let headerView = tableView.dequeueReusableHeaderFooterViewWithIdentifier("ClassHeaderView") as! ClassHeaderView
headerView.section = section
headerView.data = classes[section]
headerView.tableView = tableView
headerView.loadContent() if tmpHeadView == nil && section == { tmpHeadView = headerView
} return headerView
}
}

最新文章

  1. dbca静默建库和删除库
  2. Cache and Virtual Memory
  3. Django~Test View
  4. java 线程---成员变量与局部变量
  5. Unity上使用Linq To XML
  6. VC++中 wstring和string的互相转换实现
  7. 使用lock_sga和pre_page_sga参数保证SGA常驻物理内存 .
  8. PHP搭建简单暴力的mvc
  9. MySQL错误:You are using safe update mode and you tried to update a table without a WHERE that uses a K
  10. Direct3D中的绘制
  11. ML学习分享系列(1)_计算广告小窥[上]
  12. Python Web(Django)与SQL SERVER的连接处理
  13. PHP 以最快的方式判断字符串是否以某给定字符串开始
  14. 【BZOJ3716】[PA2014]Muzeum(贪心,网络流)
  15. List集合1
  16. java lambda 的用法
  17. 【Hadoop学习之一】Hadoop介绍
  18. 【Python】unittest-4
  19. EF数据库优先模式(一)
  20. 用Eclipse进行远程Debug代码 (转)

热门文章

  1. P1270 【“访问”美术馆】
  2. hdu 1272 判断所给的图是不是生成树 (并查集)
  3. Android Studio 入门级教程(一)
  4. Angular 快速学习笔记(1) -- 官方示例要点
  5. 002.Postfix空客户端配置
  6. Ubuntu服务器的anaconda环境修复办法(自动进入base环境怎么办?)
  7. js数据结构之链表(单链表、双向链表、循环链表)
  8. UML用例图之间的关系
  9. 纯css滚动视差
  10. ARP欺骗防御工具arpon