我已将3D Touch Peek/Pop功能添加到我的集合视图单元中并且效果很好,但是我注意到预览框架并不尊重圆角的半径细胞。Peek/Pop预览忽略集合视图中的单元圆角半径
这是我的预览功能:
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
}
我已经尝试设置previewingContext sourceView的圆角半径,并与细胞masksToBounds玩耍,但没有到目前为止,我已经试过了帮助。
这里的小区建立:
override func awakeFromNib() {
self.layer.cornerRadius = 7
}
任何人有什么建议?
嗨,你可以上传你的测试项目的地方?谢谢 –