How can I make a carousel like this? - ios

How can I make a carousel like this with UICollection view?

A UICollectionView has a collectionViewLayout which is of type UICollectionViewLayout. It is this layout object which is responsible for how the cells in a collection view are laid out.
If you want a layout object capable of stacking the cells on top of each other as in the image you've posted you can either build your own UICollectionViewLayout or use a layout which somebody has already created and made available. Examples are:
https://github.com/gleue/TGLStackedViewController
or
https://github.com/victor-pavlychko/DeckCollectionViewLayout

Related

Random UICollectionView grid

I'm about to do my first UICollectionView and from a syntax point of view it looks almost exactly the same as what you would do for a UITableView.
I'm trying to figure out how I could build a photo grid that is based on the image below.
Can this be achieved with a single UICollectionview, or do I need to do a static view for the big images and then two collectionViews beside it (yuck!) or can this be done with sections?
This can be achieved using a single collection view. You can customize your collection view using UICollectionViewLayout. UICollectionViewLayout is very powerful, and you can achieve almost every kind of layout with this. Here's a very in-depth tutorial explaining the UICollectionViewLayout. Understand it and change it to according to your needs.
Link

Collection view Cell layout issue

I am designing an app that has the following layout. I was thinking of having the view as a collectionview.
A and B are a custom collection cells. How would I design the app so that the second and third rows have 2 and 3 cells as shown in the image?
I tried over-riding the sizeForItemAt indexPath method and then calculating the size of each cell based on the row it is in.
Not only it seems a little odd and but the cells don't align properly either.
I tried setting the estimatedItemSize property as well as over-riding preferredLayoutAttributesFitting by following this link.
Is there an easier way to do this UI ? Should I remove colleciton view and go with plain ol tableviews ?
Any help would be much appreciated.

UICollectionView layout with custom layout

Is it possible to create a collection view with an item on the left and two items stacked to the right of it?
Whenever I specify the correct sizes to do this in the sizeForItemAtIndexPath delegate I can only get one item on the right side and the other is displayed in the next row underneath. I know I can do this with custom cells that contain more than one view (top and bottom) but I would like to know if its possible without that. It would be a lot less complex if I could do it without the custom double view cell. Im using a 'flow' layout with 'vertical' scroll direction (as per IB).
First image is what I hope to achieve and the second is what I am able to achieve currently.
You need to implement custom UICollectionViewFlowLayout subclass for this - Creating Custom Layouts

Customizing / subclassing UICollectionViewLayout to enable scrolling in multiple directions

I'm designing a layout for my app that is going to take advantage of UICollectionView. I have created some moderately complex collectionView-based apps before, but I may need to subclass the layout class for this one. The main point I'm trying to figure out is whether I can have different sections of the same collectionView scroll in different directions.
Based on what I have read and tried so far, the only way to have one section scroll horizontally and another vertically would be by using multiple nested instances of UICollectionView.
This is a basic idea of my layout. My guess is that even with subclassing, a single UICollectionView would not be able to handle it. Or would it?
I think you could do it with a custom UICollectionViewLayout but I'd use the default flow layout with one cell containing something like a SwipeView for the section 0 and other cells in your section 1.

UICollectionViewFlowLayout with items of different size

I have an UICollectionView where the items can modify at run time it's height.
The problem is that when an item is higher than another, the item are surrounded by a lot o blank space.
I'm looking for a property that create this:
and I want use UICollectionView not github example or third part implementation.
Thanks.
I don't believe UICollectionViewFlowLayout behaves this way. Try to reload your collection view after modifying the height or returning a different value for that cell in collectionView:layout:sizeForItemAtIndexPath: and see if the gap fills. Otherwise, I'd recommend using a custom UICollectionViewLayout subclass.
This class might fit this purpose properly - a UICollectionViewLayout subclass to work with your collection view:
https://github.com/aceisScope/WaterflowView/blob/master/WaterFlowDisplay/WaterFlowLayout.h

Resources