refresh control

override func viewDidLoad() {
    super.viewDidLoad()
    
    self.tableView.tableFooterView = UIView(frame: CGRect.zero)
    
    // refresh control
    let refreshControl = UIRefreshControl()
    refreshControl.backgroundColor = UIColor.clear
    refreshControl.tintColor = UIColor.red
    refreshControl.addTarget(self, action: #selector(refresh(refreshControl:)), for: .valueChanged)
    self.tableView.addSubview(refreshControl)
}

// selector for refresh control
func refresh(refreshControl: UIRefreshControl) {
    
    // to be done in the future.
    print("refresh")
    
    refreshControl.endRefreshing()
}

你可能感兴趣的:(refresh control)