在UICollectionView上从右向左对齐

在UICollectionView上从右向左对齐

本文介绍了在UICollectionView上从右向左对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常简单的问题,但是我无法在SO上找到对此的明确答案(如果我错过了,请纠正我).

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).

基本上,我的问题是: 是否可以从右向左而不是从左向右对齐UICollectionView行内容?

Basically, my question is: Is it possible to align UICollectionView row contents from right to left instead of from left to right?

在我的研究中,我看到了建议将子类化为UICollectionViewFlowLayout的答案,但我找不到一个为右对齐而创建的例子.

In my research I've seen answers suggesting subclassing UICollectionViewFlowLayout, but I haven't been able to find an example where one was created for right-alignment.

我的目标是像这样设置2个集合视图:

My goal is to have 2 collection views set up like this:

任何帮助将不胜感激!

推荐答案

您可以通过对集合视图执行转换并反转其内容的翻转来获得相似的结果:

You can get similar result by performing a transform on the collection view and reverse the flip on its content:

首先,当创建UICollectionView时,我对其进行了水平翻转:

First when creating the UICollectionView I performed a horizontal flip on it:

[collectionView_ setTransform:CGAffineTransformMakeScale(-1, 1)];

然后是子类UICollectionViewCell,在这里对其contentView进行相同的水平翻转:

Then subclass UICollectionViewCell and in here do the same horizontal flip on its contentView:

[self.contentView setTransform:CGAffineTransformMakeScale(-1, 1)];

这篇关于在UICollectionView上从右向左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 02:46