Skip to content

Instantly share code, notes, and snippets.

@teawithfruit
Created April 17, 2017 11:19
Show Gist options
  • Save teawithfruit/5b215a82865b1a17499ce6a9ee8363cb to your computer and use it in GitHub Desktop.
Save teawithfruit/5b215a82865b1a17499ce6a9ee8363cb to your computer and use it in GitHub Desktop.
if available – UIRefreshControl
import Foundation
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
if #available(iOS 10.0, *) {
scrollView.refreshControl = refreshControl
} else {
scrollView.alwaysBounceVertical = true
scrollView.addSubview(refreshControl)
}
}
func refresh(_ refreshControl: UIRefreshControl) {
refreshControl.endRefreshing()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment