Aligning right to left on UICollectionView

前端 未结 13 639
悲哀的现实
悲哀的现实 2020-12-02 08:31

this is a pretty straightforward question, but I haven\'t been able to find a definitive answer to it on SO (if I missed it, please correct me).

Basically, my quest

13条回答
  •  遥遥无期
    2020-12-02 09:25

    UICollectionView already support rtl direction if UICollectionViewFlowLayout is not dynamic.

    Changing Estimate size to None as the image shows automatically changed the direction of the CollectionView.

    One more issue is to scroll to the end of the collection view after reloading data.

    extension UICollectionView {
        
        func scrollToEndIfArabic() {
            if Language.shared.isArabic() {
                DispatchQueue.main.async {
                    self.contentOffset
                        = CGPoint(x: self.contentSize.width
                            - self.frame.width
                            + self.contentInset.right, y: 0)
                }
            }
        }
    }
    

提交回复
热议问题