I have gradient(clear - black) applied to an imageview and on top of it I have a float button. Everything works fine. The only issue is, whenever there is a tap on float button, the gradient start increasing to black more and more. my gradient is clear to black from top to bottom. But on interaction, It start to slowely blacken towards upside.
I am really unable to solve this error.
This image view is in a UIcollectionResuableView. Below is the code for yhe following.
func addBlackGradientLayerprof(frame: CGRect){
    let gradient = CAGradientLayer()
    gradient.frame = frame
    let black = UIColor.init(red: 0/255, green: 0/255, blue: 0/255, alpha: 0.65).cgColor
    gradient.colors = [UIColor.clear.cgColor, black]
    gradient.locations = [0.0, 1.0]
    self.layer.addSublayer(gradient)
}
Header View with floating button:
override func layoutSubviews() {
    super.layoutSubviews()
    profilePic.addBlackGradientLayerprof(frame: profilePic.bounds)
}
override func awakeFromNib() {
    super.awakeFromNib()
    layoutFAB()
}
func layoutFAB() {
    floaty.openAnimationType = .slideDown
    floaty.addItem("New Post", icon: UIImage(named: "photo-camera")) { item in
        self.delegate.fabUploadClicked()
    }
    floaty.addItem("Settings", icon: UIImage(named: "settingsB")) { item in
        self.delegate.fabSettingsClicked()
    }
    floaty.paddingY = (frame.height - 30) - floaty.frame.height/2
    floaty.fabDelegate = self
    floaty.buttonColor = UIColor.white
    floaty.hasShadow = true
    floaty.size = 45
    addSubview(floaty)
}