I'm trying to add a gradient to UIImageView.
viewDidLoad() {
self.bookImageBig.sd_setImage(with: URL(string: self.book.image), placeholderImage: nil)
self.bookImage.sd_setImage(with: URL(string: self.book.image), placeholderImage: nil)
let view = UIView(frame: bookImageBig.frame)
let gradient = CAGradientLayer()
gradient.frame = view.frame
gradient.colors = [UIColor.clear.cgColor, UIColor.black.cgColor]
gradient.locations = [0.0, 1.0]
view.layer.insertSublayer(gradient, at: 0)
bookImageBig.addSubview(view)
bookImageBig.bringSubviewToFront(view)
I'm trying to add a gradient to bookImageBig UIImageView.
However, the gradient only partially covers the image. 30px of the image is not covered by the gradient. The image was added to the story board and is being referenced in the view controller. Can someone please help?