Swift-uitableview Expanding the Zoom animation
Effect
Source
Https://github.com/YouXianMing/Swift-Animations
////Headerviewtapanimationcontroller.swift//swift-animations////Created by youxianming on 16/8/9.//copyright©2016 year youxianming. All rights reserved.//Import UIKitclassHeaderviewtapanimationcontroller:normaltitleviewcontroller, Uitableviewdelegate, UITableViewDataSource {Privatevar classes: [classmodel]!Privatevar tableview:uitableview!Privatevar sectionfirstload:bool!PrivateWeak Var tmpheadview:classheaderview!Overridefunc 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=falseaitna.students?. Append (Studentmodel (name:"y.x.m.", Age: -)) Aitna.students?. Append (Studentmodel (name:"Leif", Age: A)) Aitna.students?. Append (Studentmodel (name:"Lennon", Age: at)) Aitna.students?. Append (Studentmodel (name:"Jerome", Age: +)) Aitna.students?. Append (Studentmodel (name:"Isidore", Age: the)) Let Melete= Classmodel (className:"Melete") Melete.expend=falsemelete.students?. Append (Studentmodel (name:"Merle", Age: -)) Melete.students?. Append (Studentmodel (name:"Paddy", Age: to)) Melete.students?. Append (Studentmodel (name:"Perry", Age: -)) Melete.students?. Append (Studentmodel (name:"Philip", Age: at)) Let Aoede= Classmodel (className:"Aoede") Aoede.expend=falseaoede.students?. Append (Studentmodel (name:"Verne", Age: A)) Aoede.students?. Append (Studentmodel (name:"Vincent", Age: the)) Aoede.students?. Append (Studentmodel (name:"Walter", Age: +)) Aoede.students?. Append (Studentmodel (name:"Zachary", Age: +)) Let Dione= Classmodel (className:"Dione") Dione.expend=falsedione.students?. Append (Studentmodel (name:"Timothy", Age: the)) Dione.students?. Append (Studentmodel (name:"Roderick", Age: the)) Dione.students?. Append (Studentmodel (name:"Quentin", Age: A)) Dione.students?. Append (Studentmodel (name:"Paddy", Age: the)) Let Adanos= Classmodel (className:"Adanos") Adanos.expend=falseadanos.students?. Append (Studentmodel (name:"Mortimer", Age: +)) Adanos.students?. Append (Studentmodel (name:"Michael", Age: -)) Adanos.students?. Append (Studentmodel (name:"Kevin", Age: at)) 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=trueself.tableView.insertSections (Nsindexset (Indexesinrange:nsmakerange (0, 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]ifClassmodel.expend = =true { return(classmodel.students?). Count)! } Else { return 0}} func Numberofsectionsintableview (Tableview:uitableview)-Int {ifSectionfirstload = =false { return 0 } Else { returnClasses.count}} func TableView (Tableview:uitableview, Cellforrowatindexpath Indexpath:nsindexpa TH)-UITableViewCell {Let Classmodel=Classes[indexpath.section] Let Customcell= Tableview.dequeuereusablecellwithidentifier ("Studentinfocell") as!Customcell Customcell.data= classmodel.students![Indexpath.row] Customcell.indexpath=Indexpath customcell.loadcontent ()returnCustomcell} func TableView (Tableview:uitableview, Didselectrowatindexpath Indexpath:nsindexpath) { Tableview.selectedeventwithindexpath (Indexpath)} func TableView (Tableview:uitableview, Viewforheader Insection section:int)UIView?{Let Headerview= Tableview.dequeuereusableheaderfooterviewwithidentifier ("Classheaderview") as!Classheaderview headerview.section=Section headerview.data=Classes[section] Headerview.tableview=TableView headerview.loadcontent ()ifTmpheadview = = Nil && section = =0{Tmpheadview=Headerview}returnHeaderview}}
Swift-uitableview Expanding the Zoom animation