Skip to content

Instantly share code, notes, and snippets.

@JeremyXue77
Last active July 4, 2018 04:12
Show Gist options
  • Select an option

  • Save JeremyXue77/fd9de42eefb1e04a01523db410d2d60c to your computer and use it in GitHub Desktop.

Select an option

Save JeremyXue77/fd9de42eefb1e04a01523db410d2d60c to your computer and use it in GitHub Desktop.
@IBAction func refreshData(_ sender: Any) {
// 開始刷新動畫
refreshControl.beginRefreshing()
// 使用 UIView.animate 彈性效果,並且更改 TableView 的 ContentOffset 使其位移
// 動畫結束之後使用 loadData()
UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: UIViewAnimationOptions.curveEaseIn, animations: {
self.myTableView.contentOffset = CGPoint(x: 0, y: -self.refreshControl.bounds.height)
}) { (finish) in
self.loadData()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment