Я создаю экран списка друзей, который имеет animation
, например:
Я начал с collectionview
, но я не Не понимаю, как изменить положение cells
.
Я беру два uicollectionviewcell
один для изображения, имя и второй для всех деталей, таких как список.
Мне также удалось изменить для коллекцию в список, но для animation
я не знаю, как это сделать.
Вот мой Код:
//MARK: - Collection view setUp -
extension CollViewAnimate {
fileprivate func setUpCollView() {
self.delegate = self
self.dataSource = self
self.register(UINib(nibName: "NameCollCell", bundle: nil), forCellWithReuseIdentifier: "NameCollCell")
self.register(UINib(nibName: "DetailCollCell", bundle: nil), forCellWithReuseIdentifier: "DetailCollCell")
}
func reloadTblData() {
self.isList = !self.isList
self.reloadData()
}
}
//MARK: - Collection view Deleagtes & DataSources -
extension CollViewAnimate: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.arrFriendList.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if self.isList {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DetailCollCell", for: indexPath) as? DetailCollCell {
cell.setUserDetails(self.arrFriendList[indexPath.row])
return cell
}
} else {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "NameCollCell", for: indexPath) as? NameCollCell {
cell.setUserDetails(self.arrFriendList[indexPath.row])
return cell
}
}
return UICollectionViewCell(frame: .zero)
}
}
//MARK: - Collection view FlowLayout Deleagtes -
extension CollViewAnimate: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if self.isList {
return CGSize(width: (collectionView.frame.width), height: (collectionView.frame.width / 5))
}
return CGSize(width: (collectionView.frame.width / 3), height: (collectionView.frame.width / 2.5))
}
}
Здесь я использовал отдельный вид коллекции файл, мой весь код для collectionview
возвращается сюда, и .xib
файл для collectionviewcell
.
, пожалуйста, помогите мне выполнить эту задачу, также дайте свое предложение для подходящего controller
.
Спасибо