Skip to content

Instantly share code, notes, and snippets.

@MaherKSantina
Last active July 24, 2018 08:19
Show Gist options
  • Save MaherKSantina/eaf013735abf3c48b93b2e1afa12f721 to your computer and use it in GitHub Desktop.
Save MaherKSantina/eaf013735abf3c48b93b2e1afa12f721 to your computer and use it in GitHub Desktop.
MSPCVDI Complete Example
import UIKit
import MSPeekCollectionViewDelegateImplementation
class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
let delegate = MSPeekCollectionViewDelegateImplementation()
override func viewDidLoad() {
super.viewDidLoad()
collectionView.configureForPeekingDelegate()
collectionView.delegate = delegate
collectionView.dataSource = self
}
}
extension ViewController: UICollectionViewDataSource {
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
cell.contentView.backgroundColor = UIColor.red
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment