Skip to content

基于系统UIRefreshControl的自定义数据刷新控件,极易上手。

License

Notifications You must be signed in to change notification settings

Longroader/ZFRefresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ZFRefresh

个人开源项目,基于系统UIRefreshControl的自定义下拉刷新控件,极易上手。

使用方法

导入ZFRefresh文件夹,在tableViewController中写如下三行代码:

class ViewController: UITableViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 1.创建刷新控件,添加下拉监听
        refreshControl = ZFRefreshControl(navBar: (navigationController?.navigationBar)!)
        refreshControl?.addTarget(self, action: "loadData", forControlEvents: .ValueChanged)
    }
    
    @objc private func loadData() {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(1.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in
            
	    // 2.网络请求成功或者失败后,结束刷新
            self.refreshControl?.zf_endRefreshing(10)
        }
    }
}

示例效果

image

Thanks

受到@极客江南的启发,非常感谢!

Contribute

We welcome any contributions.

License

ZFRefresh is available under the MIT license. See the LICENSE file for more info.

About

基于系统UIRefreshControl的自定义数据刷新控件,极易上手。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages