Created
April 17, 2017 11:19
-
-
Save teawithfruit/5b215a82865b1a17499ce6a9ee8363cb to your computer and use it in GitHub Desktop.
if available – UIRefreshControl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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