iDeveloper iDeveloper - 5 months ago 37
Swift Question

How to fill data right to left in UICollectionView

I am trying to fill data from right to left, because i am designing an Arabic app. and i know it write from right to left. So how to do it?

Like This:

Desired result

Thanks.

Answer

Creation of a custom UICollectionViewFlowLayout maybe is the most straight answer, but it's too expensive. I always rather use this way (Flip the collectionView and it's subviews).

Inside init or viewDidLoad() put this:

self.collectionView.transform = CGAffineTransformMakeScale(-1, 1)

Inside collectionView:cellForItemAtIndexPath: or cell class put this:

cell.transform = CGAffineTransformMakeScale(-1, 1)