How to expand collectionview cell to full screen [closed]

本秂侑毒 提交于 2020-01-21 07:48:45

问题


I created a horizontal collection view and single cell is displayed in screen. I try to preview another views in each cell and when user swipe up the cell should expand to full screen. I don't know to how to approach this problem? How can I expand cell to fullscreen animated?


回答1:


If you want to increase cell size to fit to your screen you can use this method.

Objective-C

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
}

Swift

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        //For entire screen size
        let screenSize = UIScreen.main.bounds.size
        return screenSize
        //If you want to fit the size with the size of ViewController use bellow
        let viewControllerSize = self.view.frame.size
        return viewControllerSize

        // Even you can set the cell to uicollectionview size
        let cvRect = collectionView.frame
        return CGSize(width: cvRect.width, height: cvRect.height)


    }


来源:https://stackoverflow.com/questions/40346165/how-to-expand-collectionview-cell-to-full-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!