iOS 适配RTL(UICollectionView/UIScrollView)

UICollectionView:自定义继承UICollectionViewFlowLayout子类,重写var flipsHorizontallyInOppositeLayoutDirection: Bool

override var flipsHorizontallyInOppositeLayoutDirection: Bool {
    get{
          return true //true:RTL, false:LTR
    }
}

UIScrollView: 使用transform.scaledBy()水平翻转模拟镜像,然后scrollView的子视图scrollSubView再调用transform.scaledBy()将镜像设置回来

scrollView.transform = CGAffineTransform.identify.scaledBy(x: -1.0, y: 1.0)
scrollSubView.transform = CGAffineTransform.identify.scaledBy(x: -1.0, y: 1.0)

你可能感兴趣的:(iOS 适配RTL(UICollectionView/UIScrollView))