UICollection水平滚动,因此减少了单元格项目之间的空间 [英] UICollection horizontally scroll, so reduce the space between cell item

查看:58
本文介绍了UICollection水平滚动,因此减少了单元格项目之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UICollectionView并设置水平滚动.现在,在此一个图像视图中,除像元间距外,其他所有参数均正常工作.在collectionView中,我为单元格0(零)设置了最小间距.但是仍然有Spaces.

I take UICollectionView and set horizontal scroll. Now In this one image view is there, All working perfect except cell spacing. In collectionView I set the Minimum Spacing for cells 0(Zero). But still Spaces is there.

我的输出就是这样.

My output is like that..

但是我需要这种类型的输出.

But I need this type of output..

还有一件事,就是我提到了很多答案,但仍然不知道该怎么做.我使用Xcode 7.0,因此我需要Swift 2.0中的解决方案,如果可能的话,还要求在Swift 3.0中给出答案. 请帮我.谢谢你.

And one more thing is that I refer so many answer but still no idea what to do. I use Xcode 7.0 so I need solution in swift 2.0 and if possible then also request to give answer in swift 3.0. Please help me. Thanks in advanced.

推荐答案

尝试一下

别忘了设置collectionview布局代理

dont forget to set collectionview flowlayout delegate

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
            return CGSize(width: collectionViewTable.bounds.size.width/2 - 20, height: 160)

         }

func collectionView(_ collectionView: UICollectionView,
                        layout collectionViewLayout: UICollectionViewLayout,
                        insetForSectionAt section: Int) -> UIEdgeInsets
    {
        return  UIEdgeInsetsMake( 5,  14, 5,  14)
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
        return 20;
    }

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
        return 20;
    }

这篇关于UICollection水平滚动,因此减少了单元格项目之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆