在 UICollectionView 上从右到左对齐 [英] Aligning right to left on UICollectionView

查看:20
本文介绍了在 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 上从右到左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆