Home > Back-end >  RTL collectionView using UICollectionViewCompositionalLayout
RTL collectionView using UICollectionViewCompositionalLayout

Time:03-07

I'm trying to find a way to have a right to left UICollectionView using UICollectionViewCompositionalLayout but there's no documentation about it. has anybody an idea?

please recommend anything than flipping the UICollectionView and the cells.

CodePudding user response:

it depends on your usage if you use in tableviewcell you must set it to layoutSubviews() and if you use it in viewcontroller you must use in after viewdidload lifecycle

collectionView.semanticContentAttribute = .forceRightToLeft

CodePudding user response:

Just add below lines in your view controller.

extension UICollectionViewFlowLayout {
    
    open override var flipsHorizontallyInOppositeLayoutDirection: Bool {
        return true
    }
}

This is extension that over-ride and allow to flip horizontally for RTL layout.

  • Related