I need to know how to do to embed a UICollectionView and a UIView within a UIScrollView, but that everything moves with the scroll of UIScrollview.
the layout is something like the following image:
I need to know how to do to embed a UICollectionView and a UIView within a UIScrollView, but that everything moves with the scroll of UIScrollview.
the layout is something like the following image:
Why don't you use the view
as the collectionView
's section supplementary view (see docs)? It will become part of the collectionView
thus scrolling of the collectionView
will handle also the view
itself.
1- Drag a UIScrollview
to your vc give it leading , trailing , top and bottom constraints to the parent view
2- Drag a UIView (content-view) in side the scrollview , give it leading , trailing , top and bottom constraints to the scrollview
3- Control drag from the content-view to the main outer view and select Equal-Widths
4- Drag UIView
inside the content-view give it leading , trailing , top and a height say 300
5- Drag UIcollectionView
below the top-view give it leading , trailing to the content-View , top to the top-View and a height as you want
6- Hook bottom constraint of the collectionview to the bottom of the content-View
7- set bounces property of the collectionView to false
note: You may hook the height constraint of the collection-view and change in runtime , also it's better to use tableView instead of collection view in presenting data vertically