如何从 UICollectionView 弹出一个 uicollectionViewCell?

How to pop out a uicollectionViewCell from the UICollectionView?

你好,我有一个简单的水平 uicollectionview,我想弹出 UICollectionViewCell。

当我单击一个白色单元格时,我得到更大的尺寸但仍包含在集合视图中:->

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    // handle tap events
    let cell = collectionView.cellForItem(at: indexPath) as! MyCollectionViewCell

    print("You selected cell #\(indexPath.item)!")
    Fullscreen.originalHeight = (cell.frame.height)
    Fullscreen.originalWidth = (cell.frame.width)
    Fullscreen.originalX = (cell.frame.origin.x)
    Fullscreen.originalY = (cell.frame.origin.y)

    print(Fullscreen.originalX,Fullscreen.originalY,Fullscreen.originalWidth,Fullscreen.originalHeight)

    cell.superview?.bringSubview(toFront: cell)
    cell.clipsToBounds = true
    UIView.animate(withDuration: 0.3,
                   delay: 0,
                   options: .curveEaseOut,
                   animations: {

                    //fullscreen
                    cell.frame.size.height = (collectionView.superview?.frame.height)!
                    cell.frame.size.width = (collectionView.superview?.frame.width)!
                    cell.frame.origin.x = (collectionView.superview?.frame.origin.x)!
                    cell.frame.origin.y = (collectionView.superview?.frame.origin.y)!
    },completion: nil)

如您所见,视图被 Collectionview 的尺寸截断了

如何让它弹出并具有比集合视图更大的尺寸?

我可以增加 collectionView 的 contentSize.height,但我需要水平线上的白色单元格。

谢谢

不太清楚你到底想实现什么,也许你可以分享你的部分代码,这样我就可以看到你是如何尝试实现的。

按照你的说法,你可以试试弹出单元格时按你说的把contentSize.height调大,回车时把contentSize.height放回原来的大小白色的。