Last active
September 14, 2016 15:10
-
-
Save Baza207/f5ff5abf7b8c44e2ffb3 to your computer and use it in GitHub Desktop.
A Swift extension for UICollectionViewController to allow setting and getting a UIRefresh control in the same manor as UITableViewController.
This file contains 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
/// | |
/// Extention functions for UICollectionViewController | |
/// | |
extension UICollectionViewController { | |
/// Allows easy access to a collection view controller's refrsh control the same way as in a table view controller. | |
var refreshControl: UIRefreshControl? { | |
get { | |
return collectionView?.viewWithTag(140412014669856) as? UIRefreshControl | |
} | |
set { | |
if let oldRefreshControl = collectionView?.viewWithTag(140412014669856) as? UIRefreshControl { | |
oldRefreshControl.removeFromSuperview() | |
collectionView?.alwaysBounceVertical = false | |
} | |
if let refreshControl = newValue { | |
refreshControl.tag = 140412014669856 | |
collectionView?.addSubview(refreshControl) | |
collectionView?.alwaysBounceVertical = true | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment