Skip to content

The refresh control associated with the scroll view.

License

Notifications You must be signed in to change notification settings

TrendingTechnology/EasyRefresher

 
 

Repository files navigation

EasyRefresher

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 10.0
  • Swift 5.0

Installation

EasyRefresher is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EasyRefresher'

Preview

Usage

  • Add Refresher
tableView.refresh.header.addRefreshClosure {
    self.reqeust {
        self.tableView.refresh.header.endRefreshing()
    }
}

tableView.refresh.footer = AutoRefreshFooter(triggerMode: .percent(0.5)) {
    self.reqeust {
        self.tableView.refresh.footer.endRefreshing()
    }
}
  • Manual Trigger
tableView.refresh.header.beginRefreshing()
  • State Title
tableView.refresh.header.setTitle("loading...", for: .refreshing)

tableView.refresh.footer.setAttributedTitle(
    NSAttributedString(string: "已到最后一页", attributes: [.foregroundColor: UIColor.red]), for: .disabled
)
  • Last updated time
tableView.refresh.header.lastUpdatedTimeText = { date in
    guard let date = date else { return "暂无更新记录" }
    
    return "上次刷新时间:\(date)"
}
  • UIActivityIndicatorView Style
tableView.refresh.header.activityIndicatorStyle = .white
  • Disabled
// End refreshing and set state to disabled
tableView.refresh.footer.isEnabled = false
  • Remove
tableView.refresh.footer.removeFromScrollView()
  • Impact feedback
tableView.refresh.header.impactFeedbackMode = .on(style: .medium)
  • Custom State View
extension CustomStateView: RefreshStateful {
    
    public func refresher(_ refresher: Refresher, didChangeState state: RefreshState) {
    
    }
    
    public func refresher(_ refresher: Refresher, didChangeOffset offset: CGFloat) {
    
    }
}

tableView.refresh.footer = AppearanceRefreshFooter(stateView: CustomStateView()) {
    self.reqeust {
        self.tableView.refresh.footer.endRefreshing()
    }
}

Author

Pircate, swifter.dev@gmail.com

License

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

About

The refresh control associated with the scroll view.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.4%
  • Ruby 3.6%