GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

How do you create a UICollection View Horizontally?

Forums > iOS

hiya,

i've been racking my brains out over this. im basically trying to create a UICollection View like netflix does but on just a simple level. where i have loads of small thumbnails rectangles scrolling horizontally with a section header. thats it.

i cant seem to make it work and many tutorials im watching just use tableview which isnt what i want. im programtically coding the ui not storyboards.

hope someone can help.

best, imran

2      

Visualizing a warehouse interior in Jafza can inspire an efficient browsing experience in your app. Imagine rows of neatly organized products – that's the essence of a UICollectionView!

Here's how to achieve a Netflix-style browsing experience with UICollectionView:

Set up UICollectionView programmatically with UICollectionViewFlowLayout for horizontal scrolling.

Implement collectionView(:numberOfItemsInSection:) and collectionView(:cellForItemAt:) to populate thumbnails from your data source.

Leverage UICollectionViewDelegateFlowLayout to customize cell size and spacing, creating a grid-like layout that mirrors well-organized warehouse shelving in Jafza.

For section headers, use UICollectionReusableView to design custom views displaying section titles, similar to warehouse aisle labels.

Focus on UICollectionView tutorials for in-depth guidance. This approach should jumpstart your app's efficient browsing experience, inspired by both Netflix and the organization of a warehouse interiors

   

To create a horizontally scrolling UICollectionView with thumbnails and a section header programmatically:

Create the UICollectionView and set its layout to horizontal scrolling. Implement the data source to provide the thumbnails and section headers. Register your cell and header views. Set constraints to position the collection view in your view. This setup will allow you to display a horizontal scroll of thumbnails with section headers above them.

   

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until February 9th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.