将 UICollectionView 上的内容从右到左对齐 [英] Aligning right to left on UICollectionView with contents
问题描述
我尝试了以下问题:
更新:
将collectionView
的semanticContentAttribute
改为.forceRightToLeft
collectionView.semanticContentAttribute = .forceRightToLeft
@RajeshKumar 回答
我注意到了.items 在两个元素之间的间距太大,例如 item1
和 item2
我怎样才能减少空间和其他东西?对我来说还好.另一方面,我尝试使用 layout.minimumInteritemSpacing = 0
但它对我不起作用,而且 item3
也不行.
在viewDidLoad()中:
让alignedFlowLayout = collectionView.collectionViewLayout as?AlignedCollectionViewFlowLayoutcollectionView.transform = CGAffineTransform(scaleX: -1, y: 1)[在此处输入链接描述][1]alignedFlowLayout?.horizontalAlignment = .left
@Hemang 评论对我有用.
如果您的单元格中有任何子视图,那么您也对其进行了转换.例如
self.titleLabel.transform = CGAffineTransform(scaleX: -1, y: 1)
AlignedCollectionViewFlowLayout
I tried with the following question:
Aligning right to left on UICollectionView but it's not achieved my goal.
What I was tried:
In viewDidLoad()
:
collectionView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
In cellForItemAtIndexPath()
:
cell.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
My current CollectionView
is on the left, but I want it to look like the CollecitonView
on the right.
dataSource = ["item1","item2","item3","item4","item5","item6"]
Update:
Change semanticContentAttribute
of the collectionView
to .forceRightToLeft
collectionView.semanticContentAttribute = .forceRightToLeft
by @RajeshKumar answered
I notice. items has spacing too much between two element for example item1
and item2
How can i reduce that the space and rest of things? ok for me. on the other hand I tried with layout.minimumInteritemSpacing = 0
but it is not worked for me and item3
not alinement right too.
In viewDidLoad():
let alignedFlowLayout = collectionView.collectionViewLayout as? AlignedCollectionViewFlowLayout
collectionView.transform = CGAffineTransform(scaleX: -1, y: 1)
[enter link description here][1]alignedFlowLayout?.horizontalAlignment = .left
@Hemang comment worked for me.
If you have any subviews in your cell, then you have transform it as well. For e.g.
self.titleLabel.transform = CGAffineTransform(scaleX: -1, y: 1)
AlignedCollectionViewFlowLayout
这篇关于将 UICollectionView 上的内容从右到左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!