ios - 如何从 UICollectionView 弹出一个 uicollectionViewCell?

标签 ios swift uicollectionview uicollectionviewcell uicollectionviewlayout

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

enter image description here

当我单击一个白色单元格时,我得到更大的尺寸但仍包含在 Collection View 中:-> enter image description here

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)

如您所见, View 被 Collectionview 的尺寸截断

如何让它弹出并具有比 Collection View 更大的尺寸?

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

谢谢

最佳答案

不太清楚您实际想要实现的目标,也许您可​​以分享您的部分代码,以便我了解您是如何尝试实现的。

按照你的说法,你可以尝试在弹出cell的时候按照你说的增加contentSize.height,回到白色的时候把contentSize.height恢复到之前的大小。

关于ios - 如何从 UICollectionView 弹出一个 uicollectionViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43083762/

相关文章:

ios - Swift SpriteKit 在 SKAction.runBlock() 中运行 SKAction

swift - 在 Swift 中,访问修饰符 internal 和 public 有什么区别?

ios - 从 XIB 加载时 UICollectionViewCell 导致崩溃

ios - Collection View 中的水平滚动

xcode - UIView内的UICollectionView

objective-c - 从 UITabBarController 中删除所有项目

ios - Yelp API 业务匹配端点

ios - 为什么不向客户收费?

ios - 在iPhone iOS中播放简单的WAV文件

ios - 分组 UITableView 顶部有奇怪的空间?