0

I am looking to subclass UICollectionViewCompositionalLayout with the objective of overriding layoutAttributesForElement(in:) to get the initial layout attributes using super.layoutAttributesForElement(in: rect) and modifying the attributes if some of them are overlapping (some of my items will bleed into other sections, and if an item is overlapping with another item that I want it to move one of them down until they no longer overlap).

Are there any possible issues with this? One I’m suspecting is if layoutAttributesForItem(at:) is called then I could run into some issues since I can’t do what I’m trying to do by overriding this function.

Hunter Meyer
  • 314
  • 1
  • 10
  • any luck with this? – Vjy Aug 14 '20 at 01:16
  • @Vjy I've went ahead and overriden layoutAttributesForElements(in:) as I described and it works, but there's some bugs that I've yet to work out related to drag and drop because I haven't worked on the project in a few weeks. – Hunter Meyer Aug 15 '20 at 15:30
  • @HunterMeyer how did you do this without getting a crash? – Richard Witherspoon Mar 16 '22 at 19:07
  • I was able to subclass the UICollectionViewCompositionalLayout to use it for decorationView attributes. @RichardWitherspoon You can initialise your own class in the createLayout() function. However there are some bugs where decorationViews flicker and reuse issues that I am struggling with. – Faizyy Apr 18 '22 at 10:56

0 Answers0