をスクロールする細胞を防ぐ私はUICollectionViewの表示/非スティッキーヘッダーの後ろ
flowLayout.sectionHeadersPinToVisibleBounds = true
スティッキーヘッダを持つコレクションビューを持っている私の問題は、私のヘッダーの上半分が半透明であると私は私のセルを上にスクロールするとき、私が見ることができるということですヘッダーの後ろにあるセルのスクロール
ヘッダーの後ろのセルビューの部分を非表示にしたいとします。私のイメージでは、赤の後ろに緑色が見えないようにしています。残りの行動は、私が保持したいものです。私はこれを必要と
理由は私が
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.alwaysBounceVertical = true
collectionView.register(UINib.init(nibName: EXAMPLE_CELL_REUSE_ID, bundle: nil), forCellWithReuseIdentifier: EXAMPLE_CELL_REUSE_ID)
collectionView.register(UINib.init(nibName: EXAMPLE_HEADER_REUSE_ID, bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: EXAMPLE_HEADER_REUSE_ID)
if let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
flowLayout.headerReferenceSize = CGSize(width: 400, height: 100)
flowLayout.sectionHeadersPinToVisibleBounds = true
}
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return sections.count;
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1 //self.sections[section].1;
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let exampleCell = collectionView.dequeueReusableCell(withReuseIdentifier: EXAMPLE_CELL_REUSE_ID, for: indexPath) as! MyCellCollectionViewCell;
exampleCell.headerLabel.text = "Cell"
exampleCell.backgroundColor = UIColor.green
return exampleCell;
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionElementKindSectionHeader {
if let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: EXAMPLE_HEADER_REUSE_ID, for: indexPath) as? ExampleHeader {
// header.backgroundColor = UIColor(red: 1.0, green: 0, blue: 0, alpha: 0.5)
return header
} else {
return UICollectionReusableView()
}
}
return UICollectionReusableView()
}
を示すする必要がある非常に奥に壁紙の画像を持っている私は、ここで問題が似ているかもしれないと思うが、何の応答はありませんそれが同じ問題であるかどうかは明らかではありません。 Transparent sticky header ui collectionview don't show cells underneath
使用したコードを表示します。 – PGDev
sectionHeadersPinToVisibleBoundsを除いて、コードは標準です。とにかく投稿しました –