请帮助将采集单元发送到全屏模式。我在这里检查了所有主题: Expand a cell to full screen when selected inside UICollectionView How to expand collectionview cell to full screen Expand a cell to full screen when selected inside UICollectionView
但是无法理解如何在我的代码中应用它。 非常感谢!
我尝试了所有操作。但是照片只能在单元格中放大。单元格不是高档的。
override func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
UIView.animate(withDuration: 0.5) {
if let cell = collectionView.cellForItem(at: indexPath) as? PhotosCollectionViewCell {
UIView.animate(withDuration: 1,
delay: 0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0,
options: [],
animations: {
var screenSize = UIScreen.main.bounds.size
let height = CGFloat(self.view.frame.size.height)
let width = CGFloat(self.view.frame.size.width)
cell.photo?.frame = CGRect(x: 0, y: 0, width: width, height: height)
cell.photo?.bounds = CGRect(x: 0, y: 0, width: width, height: height)
})
cell.photo?.transform = .init(scaleX: 0.50, y: 0.50)
cell.contentView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
}
}
}