how to make a gradient button in the footer of UICollectionView in swift : i have encountered a problem. i am making an app where i need to make a button that has gradient color on it inside the footer of UICollectionView, and the problem is i can not make it via storyboard, so i have to make it programmatically within the footer of UICollectionView. But i don't know how to make it.

the thing is i have tried to make it, i have accomplished to make the basic structure of UIButton inside UICollectionView's Footer.

                case UICollectionView.elementKindSectionFooter:
                
                let footer = outerMainCollectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "Footer", for: indexPath) as! headerReusableView
                
                let button = UIButton(frame: CGRect(x: 0, y: 0, width: collectionView.frame.width - 50, height: 40))
                
                if isGuest {
                    button.backgroundColor = .red
                } else {
                    button.backgroundColor = .black
                }
                
                button.setTitle("ALL", for: .normal)
                button.setTitleColor(COLORWHITE, for: .normal)
                button.addTarget(self, action: #selector(footerButton), for: .touchUpInside)
                
                footer.addSubview(button)
                
                footer.backgroundColor = UIColor.green
                
                return footer

i want to make it gradient between light Orange and dark Orange, use any hex values for instance. and i want to make it center height of 40, and margins from all sides - top, bottom, left, right.

 Thank you in advance. :-)