I have added 3D Touch Peek/Pop functionality to my collection view cells and it works great, however I've noticed that the preview frame does not respect the corner radius of the cells.
Here's my previewing function:
func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
let viewController = storyboard?.instantiateViewControllerWithIdentifier("scholarDetailViewController") as? ScholarDetailViewController
let cellPosition = self.scholarsCollectionView.convertPoint(location, fromView: self.view)
let cellIndex = self.scholarsCollectionView.indexPathForItemAtPoint(cellPosition)
guard let previewViewController = viewController, indexPath = cellIndex, cell = self.scholarsCollectionView.cellForItemAtIndexPath(indexPath) else {
return nil
}
let scholar = self.searchBarActive ? self.searchResults[indexPath.item] as! Scholar : self.currentScholars[indexPath.item]
previewViewController.setScholar(scholar.id)
previewViewController.delegate = self
previewViewController.preferredContentSize = CGSize.zero
previewingContext.sourceRect = self.view.convertRect(cell.frame, fromView: self.scholarsCollectionView)
return previewViewController
}
I've tried setting the corner radius of the previewingContext sourceView and playing around with masksToBounds on the cell, but nothing I've tried so far has helped.
Here's the cell setup:
override func awakeFromNib() {
self.layer.cornerRadius = 7
}
Anyone have any suggestions?