Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func animateLoad(){
- listTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: ({ (timer) in
- for (index, item) in self.sorted.enumerated().reversed() {
- if let idx = self.sortedNewList.index(where: { $0.0 == item.0}) {
- self.sorted.remove(at: index)
- self.sorted.insert(self.sortedNewList[idx], at: index)
- let to = IndexPath(row: index, section: 0)
- let from = IndexPath(row: idx, section: 0)
- if let img = self.whichArrow(from: from, to: to) {
- self.direction.append(img)
- }
- UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: {
- self.tableView.beginUpdates()
- self.tableView.moveRow(at: from, to: to)
- self.tableView.endUpdates()
- }, completion: { (success) in
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: {
- self.tableView.reloadData()
- })
- })
- }
- }
- self.sorted = self.sortedNewList
- }))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement