Offsetting UIRefreshControl

前端 未结 9 1502
醉话见心
醉话见心 2020-12-14 01:14

I am currently using a JASidePanel for my application and I have a UITableViewcontroller with a UIRefreshControl as one of the ViewControllers for it. The width of my tablev

9条回答
  •  Happy的楠姐
    2020-12-14 01:57

    Swift 5:

    There are a couple of ways to change UIRefreshControl position. The setup of the refresh control is done with the most convenient way.

    Example where the refresh control is part of the scroll view:

    let refresher = UIRefreshControl()
    refresher.addTarget... // Add a proper target.
    scrollView.refreshControl = refresher
    

    Please note that you can use tableView instead of the scrollView.

    Option 1: You can play with the frame/bounds of the view.

    scrollView.refreshControl?.refreshControl.bounds.origin.x = 50
    

    Option 2: Or you can do it using Auto Layout.

    
    scrollView.refreshControl?.translatesAutoresizingMaskIntoConstraints = false
    
    scrollView.refreshControl?.topAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    scrollView.refreshControl?.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: -50).isActive = true
    

提交回复
热议问题