当我使用RxSwift填充Collection View时,CollectionView单元格的分隔符不会出现。我正在使用RxDataSources而不是类函数。我相信函数drawSeparatorIfNeeded
在此过程中没有被调用,有没有解决方法呢?
收集视图准备:
private func prepareCollectionView() {
styler.cellStyle = .card
styler.separatorLineHeight = 3.0
styler.separatorColor = UIColor(hex: "#eeeeee")
styler.shouldHideSeparators = false
collectionView?.backgroundColor = UIColor(hex: "#eeeeee")
collectionView?.register(MDCCollectionViewTextCell.self, forCellWithReuseIdentifier: "eventCell")
collectionView?.translatesAutoresizingMaskIntoConstraints = false
collectionView?.topAnchor.constraint(equalTo: navigationBar.bottomAnchor).isActive = true
collectionView?.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
collectionView?.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
collectionView?.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
collectionView?.layoutIfNeeded()
}
单元格配置:
dataSource.configureCell = { _, collectionView, indexPath, model in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "eventCell", for: indexPath) as! MDCCollectionViewTextCell
cell.textLabel?.text = model
cell.backgroundColor = .white
return cell
}
细胞结合:
Observable.just(sections)
.bindTo(collectionView!.rx.items(dataSource: dataSource))
.addDisposableTo(disposeBag)
检查Reveal中的CollectionView显示分隔符UIImageView的高度为0,但是当我使用vanilla DataSource方法时,它按预期工作。