【发布时间】:2020-11-01 07:08:07
【问题描述】:
在我的旧项目中,我在单击 cell 时做了一个小动画:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.cellForItem(at: indexPath)
cell?.transform = CGAffineTransform(scaleX: 1.15, y: 1.15)
UIView.animate(withDuration: 0.6, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0.5, options: .allowUserInteraction, animations: {
cell?.transform = CGAffineTransform.identity
}, completion: nil)
if self.fbHasLoaded == true {
performSegue(withIdentifier: "collectionViewToCookieRecipe", sender: indexPath.row)
}
}
现在我正在尝试使用rx swift 重构我的项目,但我不确定在单击collectionView 中的一个时如何获取cell。我设法得到了model 和cell,如下所示:
Observable.zip(myCollectionView.rx.itemSelected, myCollectionView.rx.modelSelected(RecipesCollectionViewCellViewModel.self))
.bind { indexPath, model in
print(model)
}.disposed(by: disposeBag)
但是我如何获得cell 以便我可以制作动画?
【问题讨论】:
标签: ios swift uicollectionview uicollectionviewcell rx-swift