Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.41 KB | None | 0 0
  1.  func animateLoad(){
  2.         listTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: ({ (timer) in
  3.             for (index, item) in self.sorted.enumerated().reversed() {
  4.                 if let idx = self.sortedNewList.index(where: { $0.0 == item.0}) {
  5.                     self.sorted.remove(at: index)
  6.                     self.sorted.insert(self.sortedNewList[idx], at: index)
  7.                     let to = IndexPath(row: index, section: 0)
  8.                     let from = IndexPath(row: idx, section: 0)
  9.                     if let img = self.whichArrow(from: from, to: to) {
  10.                         self.direction.append(img)
  11.                     }
  12.                     UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: {
  13.                         self.tableView.beginUpdates()
  14.                         self.tableView.moveRow(at: from, to: to)
  15.                         self.tableView.endUpdates()
  16.                     }, completion: { (success) in
  17.                        
  18.                         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: {
  19.                            
  20.                             self.tableView.reloadData()
  21.                         })
  22.                     })
  23.                    
  24.                    
  25.                 }
  26.             }
  27.             self.sorted = self.sortedNewList
  28.            
  29.            
  30.         }))
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement