[英]How to show only selected cell of collectionView after 2-3 second of loading CollectionView
我有 60 個項目的UICollectionView
。 在選擇集合中的項目時,我導航到下一個屏幕,並且在那里我還顯示水平UICollectionView
並且所選單元格在那里突出顯示。 現在我想在 2-3 秒的視圖后實現只顯示選定的項目(突出顯示),其余部分應該不可見(或不顯示)
首先覆蓋委托方法和didSelectItemAt
方法
你已經有了一個包含 60 個項目的數組列表。
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return list.count
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
addToList.append(objectsArray[indexPath.row])
let cell = collectionView.cellForItem(at: indexPath)
cell?.layer.borderWidth = 2.0
cell?.layer.borderColor = UIColor.gray.cgColor
}
@objc func hideChannel() {
if let channel = TVManager.shared.currentChannel {
for item in 0...self.viewModel.channelCount {
if let cell = collectionView.cellForItem(at: IndexPath(item: item, section: 0)) as? PlayerCell {
if cell.channelId != channel.id {
UIView.animate(withDuration: 0.4) {
cell.alpha = 0.0
}
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.