Grid layout with CollectionView in Swift

后端 未结 5 922
失恋的感觉
失恋的感觉 2021-01-30 14:04

I would like to achieve this result:

Searching around I found out that probably the way to do it is using UICollectionView, so no problem with that since t

5条回答
  •  醉梦人生
    2021-01-30 14:32

    The first thing I would like to say is, your all above result can be achieved from UICollectionViewFlowLayout, Which is the default layout for UICollectionView.

    UICollectionViewDelegateFlowLayout has all of the methods that can fulfill your requirements.

    1. The flowLayout has minimumLineSpacingForSectionAtIndex and minimumInteritemSpacingForSectionAtIndexfor giving the spacing between the cells(both horizontally and vertically).

    2. Its not a good way of giving cell frame in cellForItemAtIndexPath (like you submit the answer link). For that flowLayout provides a delegate for sizing cell sizeForItemAtIndexPath.

    3. About the third question, yes you can use UIVisualEffectView for bluring purpose but compatible for only after iOS 8 and has issue with iPad2 I guess. But for your problem I would blur each cell rather than collectionView itself(since cell spacing is not blur).

提交回复
热议问题