Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compositional Layout IOS 13 Group background color

I was trying to find if there is an approach we can use to give background color to a group while using compositional layout. I tried to find a direct API that i can use but didn't find anything.

like image 329
suraj Avatar asked May 26 '20 19:05

suraj


1 Answers

For those looking for the answer, here you go.

        let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(
            elementKind: FollowingCollectionViewController.sectionBackgroundDecorationElementKind)
        section.decorationItems = [sectionBackgroundDecoration]

        let layout = UICollectionViewCompositionalLayout(section: section)
        layout.register(
            SectionBackgroundDecorationView.self,
            forDecorationViewOfKind: FollowingCollectionViewController.sectionBackgroundDecorationElementKind)
like image 196
Kyle Browning Avatar answered Oct 05 '22 18:10

Kyle Browning