• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

swift-tableView数据向上收缩动画

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
//
//  TTTableViewController.swift
//  tableVIewAnimation
//
//  Created by su on 15/12/11.
//  Copyright © 2015年 tian. All rights reserved.
//

import UIKit

class TTTableViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //重载一下数据
        tableView.reloadData()
        //动画延时
        let diff = 0.05
        //获取tableview的高
        let tableHeight = self.tableView.bounds.size.height
        //获取所有的单元格
        let cells:[UITableViewCell] = self.tableView.visibleCells as [UITableViewCell]
        //遍历单元格
        for cell in cells {
            cell.transform = CGAffineTransformMakeTranslation(0, tableHeight)
        }
        //遍历cell顺序执行上移的动画
        for i in 0..<cells.count {
            let cell:UITableViewCell = cells[i] as UITableViewCell
            //根据序列号决定延时时间
            let delay = diff * Double(i)
            //执行动画
            UIView.animateWithDuration(1, delay: delay, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
                //重新回到原始位置
                cell.transform = CGAffineTransformMakeTranslation(0, 0)
                }, completion: nil)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
      
        return 20
    }

 
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
       
        cell.textLabel?.text = "数据:\(indexPath.row)"
        cell.detailTextLabel?.text = "数据\(indexPath.row)"
        return cell
    }
  
}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
swifttextfield和textview实时获取输入内容发布时间:2022-07-18
下一篇:
使用swift3.0高仿新浪微博发布时间:2022-07-18
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap