Swift - UITableView展开缩放动画

Swift - UITableView展开缩放动画

Swift - UITableView展开缩放动画

效果

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
}
}
上一篇:igem template


下一篇:ESA2GJK1DH1K基础篇: 测试APP扫描Air202上面的二维码绑定通过MQTT控制设备(兼容SIM800)