Last active
October 15, 2016 14:41
-
-
Save azimin/6a7b8d5c756bc04223f2 to your computer and use it in GitHub Desktop.
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
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { | |
guard let indexPath = collectionView.indexPathForItem(at: location), | |
let cell = collectionView.cellForItem(at: indexPath) else { return nil } | |
guard let detailViewController = storyboard?.instantiateViewControllerWithIdentifier("ColorViewController") as? ColorViewController else { return nil } | |
detailViewController.preferredContentSize = CGSize(width: 300, height: 300) | |
detailViewController.color = colors[indexPath.row] | |
previewingContext.sourceRect = cell.frame | |
return detailViewController | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment