-2

I have been googling and struggling with this for a while. what I need is basically to create UICollectionViewFlowLayout which supports both - The main collectionView header (as for instance you can create simply in UITableView by dragging view into the tableView) and section headers which are just classic section headers. So far I am able to implement the sections but without the main header...

The header has to be scrollable along with the collectionView

Please I don't want to put my CollectionView with the view to the scrollView since it is really not the option...

The expected result is this:

enter image description here

Dominik Bucher
  • 2,120
  • 2
  • 16
  • 25
  • I don't understand what you mean by "Please I don't want to put my CollectionView with the view to the scrollView"...So are wanting to have a view that is always visible, with the collectionView scrolling under it? – Jacob Boyd Aug 14 '17 at 19:24
  • @matt Well, I described the situation to be the same scenario as implementing view like header into the tableView, which implies the behavior of scrolling along with collectionView which is desired here. But thanks, I will try it. – Dominik Bucher Aug 14 '17 at 19:34
  • in that Case, simply add a extra, blank section to serve as the collectionView's header. – Jacob Boyd Aug 14 '17 at 19:35

1 Answers1

2

The thing you have called "CollectionView header" could be a header for a section that lacks any items, or it could be a decoration view.

Here's a screen shot of a proof-of-concept doing it the first way:

enter image description here

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • "when you create custom layout, you loose all of your sections implemented in the collectionView, second that I don't know how to implement the things together" I don't know what you mean by that, and it sounds like a different problem. I assure you my answer does work. I linked you to my tutorial answer on how to make a decoration view if you want to go that route. – matt Aug 14 '17 at 21:11
  • Added a screen shot suggesting that what I said does work. – matt Aug 14 '17 at 21:43
  • "I still don't see any explanation how to use different section headers in one collectionView" Then you need to ask about that. Or you could even read the documentation! But that's a different question, surely. You asked how to achieve a particular overall effect, I told you how to do it and I proved that that _is_ a way to do it. – matt Aug 14 '17 at 22:02