Andrew
Andrew

Reputation: 11

Adding cell to bottom of UI Collection View

I have a CollectionView to display array of message, but I want the cells to start displaying from the bottom. Example is WhatsApp or Telegram App for iOS (new messages starts from the bottom and populate upwards).

I am trying to transform my collection view:

messageCollectionView.transform = CGAffineTransform.init(rotationAngle: (-(CGFloat)(Double.pi)))

And then transform collection cell at cellForItemAt :

cell.transform = self.messageCollectionView.transform

But when I insert a new cell, transform cell does not appear in the collection.

Upvotes: 1

Views: 1059

Answers (2)

OverD
OverD

Reputation: 2632

I usually achieve the effect your trying to accomplish by inserting the cell at the last index with the animation of you choice.

To achieve this just utilize insertItems(at:) method. For further reading follow apples documentation

Upvotes: 2

Richard D
Richard D

Reputation: 5665

To achieve this you're looking at creating a custom UICollectionViewLayout.

This answer should point you in the right direction: https://stackoverflow.com/a/31286238/346098

Also Apple provide a tutorial for creating custom layouts: https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CreatingCustomLayouts/CreatingCustomLayouts.html

Upvotes: -1

Related Questions