swiftxcodetableviewswipeuirefreshcontrol

Make the UIRefreshControl short for swiping


When using the standard UIRefreshControl in TableView the swipe down can be too long, that is, I have to drag my finger almost to the very bottom of the screen.

Is it possible to shorten the swipe path?

var refreshControl = UIRefreshControl()

 @objc func refresh(_ sender: AnyObject) {
    // Refresh anything
 }

 override func viewDidLoad() {
    super.viewDidLoad()
    
    refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
    refreshControl.backgroundColor = UIColor.clear
    TableView.addSubview(refreshControl) 
    
    refresh(view)
 }

Thank you in advance for your help.


Solution

  • Try it.

        refreshControl.addTarget(self, action: #selector(refreshHande(_:)), for: .valueChanged)
        let ori = tableView.frame
        let temp_frame = CGRect.init(x: ori.origin.x, y: ori.origin.y, width:
        ori.size.width, height: ori.size.height/1.3 )
        tableView.frame = temp_frame
        tableView.addSubview(refreshControl)
        tableView.frame = ori