UICollectionView Decoration and Supplementary views can not be moved

前端 未结 5 2081
耶瑟儿~
耶瑟儿~ 2021-02-01 07:40

In UICollectionView decoration and supplementary views seem to be a big mystery. There seems to be next to no example code at the moment. I managed to get both type

5条回答
  •  無奈伤痛
    2021-02-01 08:03

    Hi this is an old question but there is an answer for it.

    Actually I had these issues too when I implemented my own Layout object, until I realised it is imperative to cache any layout attributes objects you create in your custom layout. There is actually a very vague reference to this in the documentation (I can't remember the precise location now) which is very easily misinterpreted.

    Essentially once you have requested a layoutAttributes object for a cell at an index path, you should retain the attributes object (e.g. retaining it in a dictionary with the index path as a key will do) and return the same attributes object for any and all subsequent requests for the attributes. If you don't do this, but instead recreate new layout attributes, animation of batch updates results in severe graphical glitches and artefacts.

提交回复
热议问题