iosswiftuicollectionviewimessage-extension

Swift - send header view behind rest of collection view


Ok I have a custom sticker app wherein Im trying to accomplish this effect, the background view behind rest of the cells:

enter image description here

So far Ive created my background view:

self.addSubview(bgView)
        self.sendSubviewToBack(bgView)

and tried

 func collectionView(_ collectionView: UICollectionView,
                        viewForSupplementaryElementOfKind kind: String,
                        at indexPath: IndexPath) -> UICollectionReusableView {

        let headerView: HeaderCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell", for: indexPath as IndexPath) as! HeaderCollectionReusableView

    self.view.sendSubviewToBack(headerView)

but the background view still appears on top of the cells. How can I do this?


Solution

  • Interesting effect!

    Have you tried:

    Example:

    Storyboard

    storyboard

    Result

    result

    Runtime

    runtime