, -.
scrollViewDidScroll
UIScrollView Bottom, UIView, UITableView.
scrollViewDidScroll
func scrollViewDidScroll(scrollView: UIScrollView) {
let scrollOffset : CGFloat = scrollView.contentOffset.y
let scrollHeight : CGFloat = scrollView.frame.size.height
let scrollContentSizeHeight : CGFloat = scrollView.contentSize.height + scrollView.contentInset.bottom
let tableFrame : CGRect = self.tableView.frame
if (scrollOffset + scrollHeight) >= scrollContentSizeHeight {
self.bottomRefreshAnimation()
} else {
if self.tableView.frame.origin.y < 0 {
UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
self.tableView.frame.origin.y = self.tableView.frame.origin.y + 40
}, completion: nil)
}
}
}
self.bottomRefreshAnimation() UIView
func bottomRefreshAnimation(){
if self.tableView.frame.origin.y > 0 {
UIView.animateWithDuration(0.4, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
self.tableView.frame.origin.y = self.tableView.frame.origin.y - 40
}, completion: nil)
populateData({ (finished) -> () in
UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
if self.tableView.frame.origin.y < 0 {
self.tableView.frame.origin.y = self.tableView.frame.origin.y + 40
}
}, completion: nil)
})
}
}
, , UITableView Origin.y 40, UIView .
,
, ,
.