How to change UICollectionView Scroll Direction?

自作多情 提交于 2019-12-31 10:43:44

问题


I have successfully implemented a UICollectionView. Is it possible to change the scrollDirection?

Can you please show how to implement it programmatically?


回答1:


This is how you create it in code with 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
}


来源:https://stackoverflow.com/questions/32292262/how-to-change-uicollectionview-scroll-direction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!