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áľ
  • 18,246
  • 4
  • 51
  • 83
Mr.Zee
  • 115
  • 1
  • 8

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áľ
  • 18,246
  • 4
  • 51
  • 83
0

In every subview of the collectionView cell do this

enter image description here

Sh_Khan
  • 93,445
  • 7
  • 57
  • 76