Swift開發(fā)之UITableView狀態(tài)切換效果

效果

源碼
https://github.com/YouXianMing/Swift-Animations
//
// TableViewTapAnimationController.swift
// Swift-Animations
//
// Created by YouXianMing on 16/8/7.
// Copyright © 2016年 YouXianMing. All rights reserved.
//
import UIKit
class TableViewTapAnimationController: NormalTitleViewController, UITableViewDelegate, UITableViewDataSource {
var adapters : NSMutableArray!
var tableView : UITableView!
override func setup() {
super.setup()
// TableView.
tableView = UITableView(frame: (contentView?.bounds)!)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .None
contentView?.addSubview(tableView!)
// Register cell.
TableViewTapAnimationCell.registerToTableView(tableView, cellReuseIdentifier: nil)
// Data source.
adapters = NSMutableArray()
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "YouXianMing", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "Animations", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "YoCelsius", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "iOS-Progrommer", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "Design-Patterns", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "Arabia-Terra", selected: false), cellHeight: 80))
adapters.addObject(TableViewTapAnimationCell.dataAdapterWithData(TapAnimationModel(name: "Swift", selected: false), cellHeight: 80))
}
// MARK: UITableView's delegate & dataSource.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return adapters.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return tableView.dequeueAndLoadContentReusableCellFromAdapter(adapters[indexPath.row] as! CellDataAdapter, indexPath: indexPath)
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.selectedEventWithIndexPath(indexPath)
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return (adapters[indexPath.row] as! CellDataAdapter).cellHeight!
}
}
以上所述是小編給大家介紹的Swift開發(fā)之UITableView狀態(tài)切換效果,希望對(duì)大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的,再此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
swift 3.0 實(shí)現(xiàn)短信驗(yàn)證碼倒計(jì)時(shí)功能
這篇文章主要介紹了swift 3.0 實(shí)現(xiàn)短信驗(yàn)證碼倒計(jì)時(shí)功能的相關(guān)資料,需要的朋友可以參考下2017-02-02
Swift 4中一些實(shí)用的數(shù)組技巧小結(jié)
這篇文章主要給大家分享了關(guān)于Swift 4中一些實(shí)用的數(shù)組技巧,文中通過示例代碼介紹的介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用swift具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03
Swift免費(fèi)短信驗(yàn)證碼實(shí)現(xiàn)及動(dòng)態(tài)倒計(jì)時(shí)功能
這篇文章主要介紹了Swift免費(fèi)短信驗(yàn)證碼實(shí)現(xiàn)及動(dòng)態(tài)倒計(jì)時(shí)功能的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02
Swift map和filter函數(shù)原型基礎(chǔ)示例
這篇文章主要為大家介紹了Swift map和filter函數(shù)原型基礎(chǔ)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07
Swift 3.1聊天界面鍵盤效果的實(shí)現(xiàn)詳解
這篇文章主要給大家介紹了Swift 3.1聊天界面鍵盤效果實(shí)現(xiàn)的相關(guān)資料,文中介紹的非常詳細(xì),相信對(duì)大家的學(xué)習(xí)或者工作具有一定的參考價(jià)值,需要的朋友們下面來一起看看吧。2017-04-04

