I have used collection view to create the following layout:
I have set the size of the layout using sizeForItemAtIndexPath method of collection view and using flow layout but what I could achieve is:
I tried reducing the width and height but even then I cannot achieve the two elements below each other.
Creating a layout that behaves like you first picture is simply not possible without writing a custom subclass of UICollectionViewLayout (as rdelmar mentioned in the comment). But I have recently experienced a similar problem as you. For me this github project was very helpful: https://github.com/chiahsien/CHTCollectionViewWaterfallLayout
It looks like you can also use this layout for you CollectionView.