如何将collectionview单元格扩展为全屏

时间:2016-10-31 16:13:30

标签: ios objective-c uicollectionview uicollectionviewcell uicollectionviewlayout

我创建了一个水平集合视图,单个单元格显示在屏幕上。我尝试在每个单元格中预览另一个视图,当用户向上滑动时,单元格应扩展为全屏。 我不知道如何解决这个问题?如何将单元格扩展为全屏动画?

1 个答案:

答案 0 :(得分:11)

如果您想增加适合屏幕的像元大小,可以使用此方法。

的Objective-C

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

夫特

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
    }
相关问题