实现的效果图
系统的 UIRefreshControl 的属性很少,就只有下面几个:
isRefreshing: Bool 判断是否正在刷新
tintColor: UIColor! 修改菊花的颜色,默认是灰色的
attributedTitle: NSAttributedString? 给刷新添加文字显示
beginRefreshing() 开始刷新
endRefreshing() 结束刷新
因为 UIRefreshControl 是继承自 UIControl,所有UIControl 的方法,他都可以使用,常用的有 添加事件
addTarget(_ target: Any?, action: Selector, for controlEvents: UIControlEvents)
实现的主要核心处理部分是上拉加载:上拉加载需要做无缝加载,需要判断是不是最后一个 section 的最后一行,如果是,拖拽时进行 上拉加载 并刷新页面
代码实现:
private let cellId = "XZTableViewCell"
class ViewController: UIViewController {
private <