我正在寻找此问题的答案,我想创建一个包含nsscollectionview的视图以显示我的产品,但我也想在之前显示一些按钮。当我这样做时,当我滚动和collectionview滚动时,按钮保持固定。我要添加一张我想要的图片 https://i.stack.imgur.com/MWbzk.png
这就是我现在拥有的,此功能创建所有视图
let layout = NSCollectionViewFlowLayout()
layout.itemSize = NSSize(width: 200, height: 300)
layout.sectionInset = NSEdgeInsets(top: 100.0, left: 10.0, bottom: 10.0, right: 10.0)
layout.minimumInteritemSpacing = 5.0
layout.minimumLineSpacing = 5.0
layout.headerReferenceSize = NSSize(width: 100, height: 200)
let collectionView = NSCollectionView()
collectionView.collectionViewLayout = layout
collectionView.isSelectable = true
collectionView.setFrameSize(NSSize(width: 10.0, height: 10.0))
collectionView.dataSource = self
collectionView.delegate = self
collectionView.backgroundViewScrollsWithContent = false;
collectionView.frame = CGRect(x: 100.0, y: 100.0, width:100.0, height:100.0)
for i in 0...1 {
for j in 0...3 {
let rect = drawImage(row: CGFloat(i),col: CGFloat(j))
collectionView.addSubview(rect)
}
}
scrolllView.documentView = collectionView
view.addSubview(scrolllView)
我假设示例图片的顶部具有某些视图,然后具有collectionview,并且它们在整个窗口中一起滚动。
有人回答吗?疯了