Skip to content

Instantly share code, notes, and snippets.

@Streek
Created March 1, 2016 21:19
Show Gist options
  • Save Streek/7603e71bc38d107c37f8 to your computer and use it in GitHub Desktop.
Save Streek/7603e71bc38d107c37f8 to your computer and use it in GitHub Desktop.
Web View Pull To Refresh.
override func viewDidLoad() {
super.viewDidLoad()
addPullToRefreshToWebView()
}
func addPullToRefreshToWebView(){
var refreshController:UIRefreshControl = UIRefreshControl()
refreshController.bounds = CGRectMake(0, 50, refreshController.bounds.size.width, refreshController.bounds.size.height) // Change position of refresh view
refreshController.addTarget(self, action: Selector("refreshWebView:"), forControlEvents: UIControlEvents.ValueChanged)
refreshController.attributedTitle = NSAttributedString(string: "Pull down to refresh...")
YourWebView.scrollView.addSubview(refreshController)
}
func refreshWebView(refresh:UIRefreshControl){
YourWebView.reload()
refresh.endRefreshing()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment