我已將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
}
任何人有什麼建議?
嗨,你可以上傳你的測試項目的地方?謝謝 –