I'm a little new to UICollectionView
, and I'm trying to build a vertical list of items with only one column/only one item per row.
Between each UICollectionViewCell
I want to have a divider line, similar to UITableView
's separator. (No I can't use UITableView
for this purpose due to other reasons.)
How should I be accomplishing this? Simply adding a 1px high UIView
to each cell? Use a "supplementary view"? Use a "decoration view"? I'm lost and no tutorials seem to indicate what would be best here.
It seems ridiculous to have to reimplement the full UICollectionViewLayout
to have some lines, but throwing the line in each cell seems sloppy. What should I be doing?
UICollectionView makes adding custom layouts and layout transitions, like those in Photos, simple to build. You're not limited to stacks and grids because collection views are customizable. You can use them to make circle layouts, cover-flow style layouts, Pulse news style layouts and almost anything you can dream up!
An object that manages an ordered collection of data items and presents them using customizable layouts.
Create a new iOS app project Select the Main storyboard from the file browser. Add a CollectionView by pressing command shift L to open the storyboard widget window. Drag the collectionView onto the main view controller.
A view that defines the behavior for all cells and supplementary views presented by a collection view.
I think the problem is with connection flow layout
You can write this code in viewDidLoad
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
//You can provide vertical
[flowLayout setMinimumInteritemSpacing:0.0f];
[flowLayout setMinimumLineSpacing:0.0f];
[self.pictureCollectionView setPagingEnabled:YES];
[self.pictureCollectionView setCollectionViewLayout:flowLayout];
[self.pictureCollectionView setBackgroundColor:[UIColor whiteColor]];
Set this as your flow layout. I once made a slide show with only one row and a column and added this as a flow layout.
Later use UIEdgeInsets or draw a border of collection cell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With