Updated 31 January 2017
UITableView is used in various places in application , but some time we need to perform animation for that we have to add some code into it.
Follow some steps:
1: in viewWillAppear method write this method.
1 2 3 4 5 6 |
override func viewWillAppear(_ animated: Bool) { listMenuArray = GlobalVariables.listMenuData; //self.listMenuTable.reloadData() self.navigationController?.isNavigationBarHidden = true animateTable() } |
2: Now define this method in class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
func animateTable() { self.listMenuTable.reloadData() let cells = listMenuTable.visibleCells let tableHeight: CGFloat = listMenuTable.bounds.size.height for i in cells { let cell: UITableViewCell = i as UITableViewCell cell.transform = CGAffineTransform(translationX: 0, y: tableHeight) } var index = 0 for a in cells { let cell: UITableViewCell = a as UITableViewCell UIView.animate(withDuration: 1.5, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, animations: { cell.transform = CGAffineTransform(translationX: 0, y: 0); }, completion: nil) index += 1 } } |
3: Here listMenuTable is UITableView Instance.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.