国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Swift > 正文

iOS UITableView展開縮放動畫實例代碼

2020-03-09 17:47:31
字體:
來源:轉載
供稿:網友

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 UIKitclass 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   = 60  tableView.sectionHeaderHeight = 30  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: 27))  Aitna.students?.append(StudentModel(name: "Leif", age: 12))  Aitna.students?.append(StudentModel(name: "Lennon", age: 23))  Aitna.students?.append(StudentModel(name: "Jerome", age: 19))  Aitna.students?.append(StudentModel(name: "Isidore", age: 15))    let Melete = ClassModel(className: "Melete")  Melete.expend = false  Melete.students?.append(StudentModel(name: "Merle", age: 17))  Melete.students?.append(StudentModel(name: "Paddy", age: 31))  Melete.students?.append(StudentModel(name: "Perry", age: 59))  Melete.students?.append(StudentModel(name: "Philip", age: 23))    let Aoede = ClassModel(className: "Aoede")  Aoede.expend = false  Aoede.students?.append(StudentModel(name: "Verne", age: 12))  Aoede.students?.append(StudentModel(name: "Vincent", age: 89))  Aoede.students?.append(StudentModel(name: "Walter", age: 43))  Aoede.students?.append(StudentModel(name: "Zachary", age: 21))  let Dione = ClassModel(className: "Dione")  Dione.expend = false  Dione.students?.append(StudentModel(name: "Timothy", age: 72))  Dione.students?.append(StudentModel(name: "Roderick", age: 34))  Dione.students?.append(StudentModel(name: "Quentin", age: 12))  Dione.students?.append(StudentModel(name: "Paddy", age: 75))    let Adanos = ClassModel(className: "Adanos")  Adanos.expend = false  Adanos.students?.append(StudentModel(name: "Mortimer", age: 43))  Adanos.students?.append(StudentModel(name: "Michael", age: 64))  Adanos.students?.append(StudentModel(name: "Kevin", age: 23))  Adanos.students?.append(StudentModel(name: "Jeremy", age: 21))    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(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]  if classModel.expend == true {      return (classModel.students?.count)!     } else {     return 0  } }  func numberOfSectionsInTableView(tableView: UITableView) -> Int {    if sectionFirstLoad == false {      return 0     } 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 == 0 {      tmpHeadView = headerView  }    return headerView }}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到swift教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 交口县| 陕西省| 兴义市| 密云县| 布拖县| 晴隆县| 买车| 筠连县| 永川市| 武隆县| 闻喜县| 丹东市| 徐汇区| 色达县| 萍乡市| 祁门县| 射洪县| 崇明县| 化隆| 陆丰市| 巴中市| 郓城县| 石楼县| 衡南县| 敦化市| 沙湾县| 富阳市| 镇坪县| 锡林浩特市| 沙湾县| 米林县| 通江县| 濮阳县| 陆川县| 县级市| 临沂市| 泊头市| 内乡县| 安乡县| 凤凰县| 新津县|