I have an UIScrollView
which has a fade-out bottom gradient layer (like in below screeshot). I want to remove it when reached to bottom of UIScrollView
. I found below posts but nothing worked for me.
https://stablekernel.com/how-to-fade-out-content-using-gradients-in-ios/
let gradient = CAGradientLayer()
gradient.frame = myTextView.bounds
gradient.colors = [UIColor.clear.cgColor, UIColor.black.cgColor, UIColor.black.cgColor, UIColor.clear.cgColor]
gradient.locations = [0, 0.0, 0.7, 1]
myTextView.layer.mask = gradient
override func layoutSubviews() {
gradient.frame = kvkkTextView.bounds
}
When I try to change the frame of gradient in
private func updateGradientFrame() {
gradient.frame = CGRect(
x: 0,
y: kvkkTextView.contentOffset.y,
width: kvkkTextView.bounds.width,
height: kvkkTextView.bounds.height
)
}
It causes a weird bug. When I scroll it, texts seen on screen slowly (When I fastly scroll it, screen seen blank and then text appears).