如何将集合视图单元格扩展到全屏



我试图在全屏上打印图像我使用uicollectionviewdelegatflowlayout这里我的代码是

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        let itemWidth = collectionView.bounds.width
        let itemHeight = collectionView.bounds.height
        return CGSize(width: itemWidth, height: itemHeight)
    }

但它不会全屏显示内容它会在上下留出空间

如果你想增加单元格的大小以适应你的屏幕,你可以使用这个方法。

objective - c

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
}
<标题>迅速h1> /html>

最新更新