Skip to content

Instantly share code, notes, and snippets.

@azimin
Last active October 15, 2016 14:41
Show Gist options
  • Save azimin/6a7b8d5c756bc04223f2 to your computer and use it in GitHub Desktop.
Save azimin/6a7b8d5c756bc04223f2 to your computer and use it in GitHub Desktop.
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