Skip to content

A classic refresh effect in iOS called sticky candy.

Notifications You must be signed in to change notification settings

ZeroOnet/ZNStickyRefresher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 

Repository files navigation

ZNStickyRefresher

A classic refresh effect called sticky candy at QQ in iOS. (simple simulation)

You can use it by those codes:

lazy var stickyRefreshControl: ZNStickyRefreshControl = {
  let result = ZNStickyRefreshControl()
  result.addTarget(self, action: #selector(loadData), for: .valueChanged)
        
  return result
}()

tableView.stickyRefreshControl = stickyRefreshControl

@objc private func loadData() {
  // simulate network time waste
  DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) { 
    self.cellsCount += 1
            
    self.tableView.reloadData()
            
    // if refresh failed, modify result tag
    //self.stickyRefreshControl.isSuccessful = false
            
    self.stickyRefreshControl.endRefreshing()
  }
}

The next gif show the effect:

image

You can know it with this blog: http://blog.csdn.net/ZeroOnet/article/details/78160592 (Chinese, ^_^)

About

A classic refresh effect in iOS called sticky candy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages