Aligning right to left on UICollectionView Aligning right to left on UICollectionView ios ios

Aligning right to left on UICollectionView


Without doing any Xtransform to the collection view, simply forced RTL:

YourCollectionView.semanticContentAttribute = UISemanticContentAttribute.forceRightToLeft


You can get similar result by performing a transform on the collection view and reverse the flip on its content:

First when creating the UICollectionView I performed a horizontal flip on it:

[collectionView_ setTransform:CGAffineTransformMakeScale(-1, 1)];

Then subclass UICollectionViewCell and in here do the same horizontal flip on its contentView:

[self.contentView setTransform:CGAffineTransformMakeScale(-1, 1)];


In addition to Tawfik's answer:

You can also set UICollectionView's Semantic property via Interface Builder:

Storyboard

More about this property: in this question