0
button.backgroundColor = .black
        button.layer.borderWidth = 2
        button.layer.borderColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1.0).cgColor
        button.layer.cornerRadius = 12
        button.layer.shadowColor = UIColor.white.cgColor
        button.layer.shadowOffset = CGSize(width: 0, height: 1)
        let gradientLayer = CAGradientLayer()
        let colors = [ UIColor(red: 0.09, green: 0.412, blue: 1, alpha: 1).cgColor, UIColor(red: 0.875, green: 0.38, blue: 0.918, alpha: 1).cgColor]

        gradientLayer.colors = colors

        gradientLayer.transform = CATransform3DMakeRotation(CGFloat.pi / 2, 0, 0, 1)
        print(CGRect(x: self.button.frame.minX - 4.5, y: self.button.frame.minY - 3.5, width: viewWidthSize, height: viewHightSize))
        gradientLayer.frame = CGRect(x: self.button.frame.minX - 3.5, y: self.button.frame.minY - 2.5, width: viewWidthSize , height: viewHightSize - 0.5)
        gradientLayer.cornerRadius = 12
        let shadowLayer = CALayer()
        shadowLayer.frame = gradientLayer.bounds
        shadowLayer.shadowColor = UIColor.white.cgColor
        shadowLayer.shadowOpacity = 1.0
        shadowLayer.shadowPath = CGPath(rect: shadowLayer.bounds, transform: nil)
        gradientLayer.mask = shadowLayer
        backView.layer.sublayers?.filter{ $0 is CAGradientLayer }.forEach{ $0.removeFromSuperlayer() }

        self.backView.layer.insertSublayer(gradientLayer, below: self.button.layer)

I want like Shadow background image

But i got like Without shadow Image

Duncan C
  • 122,346
  • 22
  • 162
  • 258
SoumyaRMO
  • 1
  • 2

0 Answers0