欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2016年08月10日 09:51:03   作者:YouXianMing  
這篇文章主要介紹了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   = 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
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Swift實現(xiàn)簡易計算器功能

    Swift實現(xiàn)簡易計算器功能

    這篇文章主要為大家詳細介紹了Swift實現(xiàn)簡易計算器功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Swift中如何避免循環(huán)引用的方法

    Swift中如何避免循環(huán)引用的方法

    本篇文章主要介紹了Swift中如何避免循環(huán)引用的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • Swift中常量和變量的區(qū)別與聲明詳解

    Swift中常量和變量的區(qū)別與聲明詳解

    Swift語言同樣和Java和OC等語言一樣是同樣是需要聲明常量和變量的,下面就讓我們來學習一下Swift的常量和變量。這篇文章主要給大家介紹了關(guān)于Swift中常量和變量的區(qū)別與聲明的相關(guān)資料,需要的朋友可以參考下。
    2017-11-11
  • swift如何利用系統(tǒng)庫將漢字轉(zhuǎn)換為拼音詳解

    swift如何利用系統(tǒng)庫將漢字轉(zhuǎn)換為拼音詳解

    將漢字轉(zhuǎn)換為拼音更利于我們大家開發(fā)搜索功能,所以這篇文章主要給大家介紹了關(guān)于swift如何利用系統(tǒng)庫將漢字轉(zhuǎn)換為拼音的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-10-10
  • Swift中的條件切換語句switch...case學習教程

    Swift中的條件切換語句switch...case學習教程

    這篇文章主要介紹了Swift中的條件切換語句switch...case學習教程,Swift中的switch...case支持的數(shù)據(jù)類型很多,非常之強大,需要的朋友可以參考下
    2016-04-04
  • Switch語句的技巧

    Switch語句的技巧

    switch語句對一個表達式求值,將結(jié)果與 case 子語句比較,如果匹配,則從 case 處的語句向下執(zhí)行,本文給大家介紹Switch語句的技巧,需要的朋友參考下吧
    2016-02-02
  • 詳解如何在SwiftUI中創(chuàng)建懸浮操作按鈕

    詳解如何在SwiftUI中創(chuàng)建懸浮操作按鈕

    懸浮操作按鈕(Floating Action Button, FAB)是一種在 Android 和 Material Design 中使用的 UI 元素,它用于觸發(fā)特定屏幕的主要操作,下面我們就來詳細介紹一下如何在SwiftUI中創(chuàng)建懸浮操作按鈕,需要的朋友可以參考下
    2023-10-10
  • Swift?并發(fā)修改Sendable?閉包實例詳解

    Swift?并發(fā)修改Sendable?閉包實例詳解

    這篇文章主要為大家介紹了Swift?并發(fā)修改Sendable?閉包實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-10-10
  • swift4更新中所遇到的一些問題總結(jié)

    swift4更新中所遇到的一些問題總結(jié)

    這篇文章主要給大家介紹了關(guān)于在swift4更新中所遇到的一些問題,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2017-12-12
  • Swift讀取App的版本信息與PCH文件詳解

    Swift讀取App的版本信息與PCH文件詳解

    這篇文章主要介紹了Swift讀取App的版本信息與PCH文件的相關(guān)資料,文中通過圖文介紹的非常詳細,對大家具有一定的參考價值,需要的朋友們下面來一起看看吧。
    2017-03-03

最新評論