ios - how to get the instance of the decoration view in the collection view? -


i've implemented uicollectionview custom layout. know how present visual adornments entire collection view, don't know how present different image every section. need instance of decoration view indexpath. found on apple document:

use method create layout attributes object decoration view in collection view. decoration views type of supplementary view not present data managed collection view’s data source. instead, present visual adornments section or entire collection view.

it decide how use indexpath parameter identify given decoration view. typically, use decorationviewkind parameter identify type of decoration view , indexpath information distinguish between different instances of view.

who can tell me how in detail?

thanks lot!

answer own question! this article!

first, subclass uicollectionviewlayoutattributes , add property want.

second, in function layoutattributesfordecorationviewofkind(elementkind: string, atindexpath indexpath: nsindexpath) -> uicollectionviewlayoutattributes!, set property.

third, in uicollectionreusableview class, override function applylayoutattributes: custom uicollectionviewlayoutattributes instance contains property.

done!