1,用pod引入MJRefesh框架
2,在swift中创建桥街头文件Bridging_Header.h,并在头文件中引入MJRefresh,#import "MJRefresh.h",如下图:
-
3,在swift中直接用下面这个方法貌似没有图标
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
//Call this Block When enter the refresh status automatically
}];
或
// Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadNewData])
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
// Enter the refresh status immediately
[self.tableView.header beginRefreshing];
- 不过别担心,用下面的方式就可以了:
// 顶部刷新
let header = MJRefreshNormalHeader()
// 底部刷新
let footer = MJRefreshAutoNormalFooter()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
// 顶部刷新
header.setRefreshingTarget(self, refreshingAction: #selector(headerRefresh))
header.setTitle("你拉我干什么,你个臭流氓。。。", for: .pulling)
header.setTitle("走开走开啦", for: .refreshing)
self.tableView.mj_header = header
// 底部刷新
footer.setRefreshingTarget(self, refreshingAction: #selector(footerRefresh))
self.tableView.mj_footer = footer
}
// 顶部刷新
@objc fileprivate func headerRefresh(){
print("下拉刷新")
self.tableView.mj_header.endRefreshing()
}
// 底部刷新
@objc fileprivate func footerRefresh(){
print("上拉刷新")