-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATableView.swift
More file actions
34 lines (28 loc) · 1.36 KB
/
ATableView.swift
File metadata and controls
34 lines (28 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// ATableView.swift
// We4G
//
// Created by aviv-inmanage on 17/08/2019.
// Copyright © 2019 Inmanage. All rights reserved.
//
import UIKit
extension UITableView {
/// a func which should be called at willDisplay cell UITableView function
/// this func will create animation for all the cells in the tableview in initialization
/// and every time you reload a cell
///
/// - Parameters:
/// - animationFactory: Animation object which is needed for the animate function
/// - tableView: UITableView
/// - cell: UITableViewCell which is being animated
/// - indexPath: IndexPath of the animated cell
func animateCells(_ animationFactory: @escaping Animator.Animation, tableView: UITableView, cell: UITableViewCell, indexPath: IndexPath ) {
let animation = animationFactory
let animator = Animator(animation: animation)
animator.animate(cell: cell, at: indexPath, in: tableView)
}
//EXAMPLE: paste the commented code below into a conntroller which conforms UITableViewDelegate
// func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
// tableView.animateCells(AnimationFactory.makeMoveUpWithFade(rowHeight: cell.frame.height, duration: 0.5, delayFactor: 0.05), tableView: tableView, cell: cell, indexPath: indexPath)
// }
}