I want to use UICollectionView to free up space between lines.

Asked 2 years ago, Updated 2 years ago, 152 views

macOS High Sierra 10.13.5
Xcode 9.4.1
Objective-C
I am creating an app exclusively for iPad.

200 cells in 1 Section using UICollectionView.
I would like to make space every two lines as shown in the image below.

Enter a description of the image here

I thought it would be possible to use the subclassification of UICollectionViewDelegateFlowLayout and UICollectionViewLayout, but I can't find a good way.
(Is it impossible to arrange this within 1 Section...)

If you know how to make it happen, could you please let me know?

ios xcode objective-c

2022-09-30 21:32

1 Answers

It's not just a single UICollectionView answer, but I'll think of a way like this.

First of all, it is assumed that the size of one cell is constant.
Then you can calculate the number of elements in two lines (hereafter, the number of block elements).
(In this example, the number of block elements is 22.)I see)

You can create one large cell that contains the number of block elements and arrange them vertically in the UICollectionView.

The UI that contains the number of block elements can be just a view, or I think you can use UICollectionView.

It may not be very beautiful, but if this requirement is mast, how about one option?


2022-09-30 21:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.