Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (29 sloc) 1.14 KB
//
// UIRefreshControlExtensions.swift
// SwifterSwift
//
// Created by ratul sharker on 7/24/18.
// Copyright © 2018 SwifterSwift
//
#if os(iOS)
import UIKit
// MARK: - Methods
public extension UIRefreshControl {
/// SwifterSwift: Programatically begin refresh control inside of UITableView.
///
/// - Parameters:
/// - tableView: UITableView instance, inside which the refresh control is contained.
/// - animated: Boolean, indicates that is the content offset changing should be animated or not.
/// - sendAction: Boolean, indicates that should it fire sendActions method for valueChanged UIControlEvents
func beginRefreshing(in tableView: UITableView, animated: Bool, sendAction: Bool = false) {
// https://stackoverflow.com/questions/14718850/14719658#14719658
assert(superview == tableView, "Refresh control does not belong to the receiving table view")
beginRefreshing()
let offsetPoint = CGPoint(x: 0, y: -frame.height)
tableView.setContentOffset(offsetPoint, animated: animated)
if sendAction {
sendActions(for: .valueChanged)
}
}
}
#endif
You can’t perform that action at this time.