IOS swift UICollectionView中cell的间距如何设置,请大神讲解。
PHP中文网
PHP中文网 2017-04-18 09:28:50
0
3
803

最好能有个demo,感激不尽~

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
洪涛

You can use autolayerout to set it in the storyboard. This is my general approach because it is simple and fast. Alternatively, you can use this protocol UICollectionViewDelegateFlowLayout

Rewrite a function of the collectionview below

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets { 
        return sectionInsets
    }

Then define the following variable outside the function, which is the same as the value returned above.

 private let sectionInsets = UIEdgeInsets(top: -5.0, left: 5.0, bottom: 0.0, right: 5.0)

For the rest, you can refer to this http://www.cnblogs.com/ios8/p...

洪涛

Do you know how to set up OC? The interfaces are similar

巴扎黑
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets { 
        return sectionInsets
    }

Override this method, which is used to specify the interval, the upper, lower, left, and right intervals.

Welcome to follow Brother Biao’s technical blog: http://www.huangyibiao.com/

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template