You can use the new refreshControl property on the UICollectionView to assign your UIRefreshControl.
(Xcode 8, Swift 3.0)
override func viewDidLoad() { super.viewDidLoad() collectionView.delegate = self collectionView.dataSource = self refreshControl.addTarget(self, action: #selector(CollectionVC.refreshData), for: UIControlEvents.valueChanged) refreshControl.attributedTitle = NSAttributedString(string: "Refresh Collection View", attributes: nil) if #available(iOS 10.0, *) { collectionView.refreshControl = refreshControl } else { collectionView.addSubview(refreshControl) } } func refreshData() { // Your get data code collectionView.reloadData() refreshControl.endRefreshing() }
(Xcode 8, Swift 3.0)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.