0

Assuming I'm on a chat scenario, I want user images to move along with scroll until the other user's messages appear. Some visual example:

enter image description here

I'm using a subclass of UICollectionViewFlowLayout to display the messages and provide that initial left offset for the messages (the sectionInset property is not working on iOS 9 for some reason) and I assumed handling a custom supplementary view to do what's shown above should not be that hard, but apparently it is :)

Some info:

  • I'm not using standard header/footers for flowLayout since it add a space between sections that I don't want
  • Found this link which is pretty interesting from performance perspective but the example is somehow incomplete (great post though)
  • I'm trying to avoid shouldInvalidateLayoutForBoundsChange: to return true and recreate attributes every time since chat cells can be complex in terms of size calculation.

I believe this is not a weird scenario, have anyone accomplish something like this successfully? If so, I would appreciate some pointers.

Thank you in advance.

Community
  • 1
  • 1
Omer
  • 5,470
  • 8
  • 39
  • 64

1 Answers1

0

you can use sections for each cell groups. When using sections they have to be a clear background and be customized. So message cells can be scrolled below sections and circle images on section will be on top of its cells.

As a second way, you can use circle images apart from all collection items. For this, you have to create circle images that how many required. While scrolling up/down, they have to be moved as they will be anchored on top of message cells group.

I hope it helps for you :)

Kaan Esin
  • 70
  • 7