「右」ボタンをクリックして配列から次の5項目までスクロールさせるUICollectionViewセルを作成する必要があります。 「左ボタン」をクリックします。UICollectionViewのセルを左右のボタン操作でスクロールします。
誰もが、それは迅速にpossbile作るためにどんな提案を与えることによって私を助けることができます。
以下は、書かれたコードです。コレクションビューのリストを横スクロールで表示します。
override func viewDidLoad() {
super.viewDidLoad()
self.arrFalconList = ["ic_falcon_1","ic_falcon_2","ic_falcon_3","ic_falcon_4","ic_falcon_5","ic_falcon_6","ic_falcon_7"]
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.arrFalconList.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let aFalconCell = collectionView.dequeueReusableCell(withReuseIdentifier: "FalconCollectionViewCell", for: indexPath) as! FalconCollectionViewCell
aFalconCell.imgFalcon.image = UIImage(named: self.arrFalconList[indexPath.row])
aFalconCell.lblFalcon.text = self.arrFalconList[indexPath.row]
aFalconCell.imgFalcon.layer.cornerRadius = ((aFalconCell.imgFalcon.frame.width)/2)
aFalconCell.imgFalcon.clipsToBounds = true
if aFalconCell.isSelected {
aFalconCell.imgFalcon.layer.borderColor = UIColor.init(red: 241.0/255.0, green: 55.0/255.0, blue: 61.0/255.0, alpha: 1.0).cgColor
aFalconCell.imgFalcon.layer.borderWidth = 2
}else{
aFalconCell.imgFalcon.layer.borderColor = UIColor.clear.cgColor
aFalconCell.imgFalcon.layer.borderWidth = 0
}
return aFalconCell
}
「左」&「右」ボタンクリックイベントを処理するためにあなたの答えを共有してください。
このコードを試すことができます。 @Akash Thakkar –