如何更改 UICollectionView 滚动方向? [英] How to change UICollectionView Scroll Direction?
本文介绍了如何更改 UICollectionView 滚动方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经成功实现了一个 UICollectionView
.是否可以更改 scrollDirection
?
I have successfully implemented a UICollectionView
. Is it possible to change the scrollDirection
?
能否请您展示如何以编程方式实现它?
Can you please show how to implement it programmatically?
推荐答案
这是您在代码中使用 UICollectionViewFlowLayout
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
let collectionView = UICollectionView(frame: frame, collectionViewLayout: layout)
或者如果您正在使用现有的集合视图
or if you are working with an existent collection view
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .vertical
}
这篇关于如何更改 UICollectionView 滚动方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文