Has anyone implemented a gradient shadow for a view (same as that of the gradience in the view)? I am looking into adding a CAGradientLayer
as a sublayer and adding some filter or alike - no progress yet
I am able to apply a non-gradient shadow via something of this sort
func applyPremiumShadow(color: UIColor = .orange,
alpha: Float = 1,
x: CGFloat = 0,
y: CGFloat = 2,
blur: CGFloat = 4,
spread: CGFloat = 0) {
shadowColor = color.cgColor
shadowOpacity = alpha
shadowOffset = CGSize(width: x, height: y)
shadowRadius = blur / 2.0
if spread == 0 {
shadowPath = nil
} else {
let dx = -spread
let rect = bounds.insetBy(dx: dx, dy: dx)
shadowPath = UIBezierPath(rect: rect).cgPath
}
}