I have a requirements of adding gradient over some portion (only in left and right side ) of UIImageView. I know, this can be done by using CAGradientLayer(). But I am confused with properties locations and colors.
Below is my code. It is adding gradient at top and bottom.
if let containerView = imageView.superView {
let gradient = CAGradientLayer(layer: containerView.layer)
gradient.frame = containerView.bounds
gradient.colors = [UIColor.clear.cgColor, UIColor.blue.cgColor ,UIColor.blue.cgColor, UIColor.clear.cgColor]
gradient.locations = [0.0 , 0.25 , 0.85 , 1.0]
containerView.layer.mask = gradient
}
Thanks In Advance