0
func collectionView(_ collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout,sizeForItemAt indexPath: IndexPath) -> CGSize {
    var x = CGSize(width: 88, height: 88)

    if currentCollectionviewMode == .photos {
        if indexPath.row == 0 {
            x = CGSize(width: 88, height: 88)
        } else {
            x = CGSize(width: CGFloat(originalImages[indexPath.row - 1].size.width) / CGFloat(originalImages[indexPath.row - 1].size.height) * 88, height: 88)
        }
    } else {
        x = CGSize(width: 88, height: 88)
    }
    return x
}

before running this code everything is well, but when this code run my collectionView align change from rtl to ltr my semantic is forceRightToLeft, any suggestion?

I tried CGATransform(scaleX:-1,y:1) but collectionviewcells stick to left and with scrollToitem in viewDidAppear() collectionview show cells bad.

Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
Mr.Zee
  • 125
  • 1
  • 9

2 Answers2

2

To define a different alignment of cells in collectionView, you will have to either implement your own UICollectionViewLayout (see this answer for reference), or use some library for that (e.g., AlignedCollectionViewFlowLayout).

Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
0

In every subview of the collectionView cell do this

enter image description here

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87