如何关闭collectionView(UICollectionViewCompositionalLayout)中的滚动部分?

时间:2021-04-28 15:27:27

标签: ios swift uicollectionview uikit uicollectionviewcompositionallayout

你能帮我解决我的问题吗? 我有不同类型部分的集合视图:

  1. 水平滚动,
  2. 标签
  3. 标签内容。

我将选项卡作为部分,当用户按下选项卡时,我只调用 collectionView.scrollToItem(at indexPath + 1) 并且效果很好。 我的内容部分有问题。我做的就像水平旋转木马,我必须关闭它的滚动。 这是本节的代码。

fileprivate static var tabContantLayout: NSCollectionLayoutSection {
    get {
        let sectionBackground = NSCollectionLayoutDecorationItem.background(
                elementKind: "background")
        let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(1))
        let item = NSCollectionLayoutItem(layoutSize: itemSize)
        
        let groupSize = NSCollectionLayoutSize(
            widthDimension: .fractionalWidth(1),
            heightDimension: .estimated(1))
        let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
        let section = NSCollectionLayoutSection(group: group)
        section.orthogonalScrollingBehavior = .continuous
        
        section.decorationItems = [sectionBackground]
        return section
    }
}

如果我将 section.orthogonalScrollingBehavior 更改为 none,所有项目都将一一垂直定位。

collection view screen

请问,如果您知道如何仅在此部分中关闭滚动?谢谢

0 个答案:

没有答案
相关问题