Last active
July 24, 2018 08:19
-
-
Save MaherKSantina/eaf013735abf3c48b93b2e1afa12f721 to your computer and use it in GitHub Desktop.
MSPCVDI Complete Example
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
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