美文网首页
流动效果的TableView展现实现

流动效果的TableView展现实现

作者: 89aa04642c48 | 来源:发表于2016-03-30 13:39 被阅读159次

代码地址:https://github.com/w11p3333/LLXAnimateTableview
效果如下:

IMG_3085.GIF

主要实现:

func animationTable() {
    
    self.tableView.reloadData()
    
    let cells = tableView.visibleCells
    let tableHeight: CGFloat = tableView.bounds.size.height
    
    for i in cells {
        let cell: UITableViewCell = i as UITableViewCell
        cell.transform = CGAffineTransformMakeTranslation(0, tableHeight)
    }
    
    var index = 0
    
    for a in cells {
        let cell: UITableViewCell = a as UITableViewCell
        UIView.animateWithDuration(1.0, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
            cell.transform = CGAffineTransformMakeTranslation(0, 0);
            }, completion: nil)
        
        index += 1
    }
}

然后在viewWillAppear中调用它

相关文章

网友评论

      本文标题:流动效果的TableView展现实现

      本文链接:https://www.haomeiwen.com/subject/mjaslttx.html