I'm trying to create a left aligned collection view. The most poplar way of achieving this seems to be by using Custom Collection view layouts (ex: https://stackoverflow.com/a/36016798/11515703). However, I'm trying to do this without using Custom Layout, because it removes the collection view section headers I've got setup. Is this possible?
I tried doing this like this:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
let inset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: view.frame.width)
return inset
}
The above code achieves the result but it leads to a lot of issues as it conflicts with the collection view flow layout rules. Is there an alternative method ?
This is the result I'm trying to achieve:
Note: I'm using collection view cells with variable width.