Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当到达底部时,移除底部的ScrollView渐变淡入_Ios_Swift_Uiscrollview_Cagradientlayer - Fatal编程技术网

Ios 当到达底部时,移除底部的ScrollView渐变淡入

Ios 当到达底部时,移除底部的ScrollView渐变淡入,ios,swift,uiscrollview,cagradientlayer,Ios,Swift,Uiscrollview,Cagradientlayer,我有一个UIScrollView,它有一个淡出的底部渐变层(如下面的screeshot)。我想在到达UIScrollView底部时将其删除。我在下面找到了一些帖子,但对我来说没什么用 当我试图改变梯度的框架时 private func updateGradientFrame() { gradient.frame = CGRect( x: 0, y: kvkkTextView.contentOffset.y, width: kvkkTextView.bounds.wid

我有一个
UIScrollView
,它有一个淡出的底部渐变层(如下面的screeshot)。我想在到达
UIScrollView
底部时将其删除。我在下面找到了一些帖子,但对我来说没什么用

当我试图改变梯度的框架时

private func updateGradientFrame() {
gradient.frame = CGRect(
    x: 0,
    y: kvkkTextView.contentOffset.y,
    width: kvkkTextView.bounds.width,
    height: kvkkTextView.bounds.height
)
}
它会引起一个奇怪的错误。当我滚动它时,屏幕上显示的文本会慢慢变慢(当我快速滚动它时,屏幕显示为空白,然后文本就会出现)

试试这个

func scrollViewDidScroll(_ scrollView: UIScrollView) {

    updateGradientFrame()

    //On the scroll view content is over means there is no content anymore then hide the mask
    if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.bounds.height {

        label.layer.mask = nil
    } else {

        //Else show the mask of UILabel
        label.layer.mask = gradient
    }
}
更新:

private func updateGradientFrame() {
    gradient.frame = CGRect(
        x: 0,
        y: scrollView.contentOffset.y,
        width: scrollView.bounds.width,
        height: scrollView.bounds.height
        )
}

GitHub Url:

我有上面教程的完整源代码。如果您需要,我可以发送给您,@EmreÖnder。您也可以共享UpdateGraientFrame()吗?因为一切都在进行updateGradientFrame(),我在前面的不同帖子中看到了这个答案,但这导致了一个奇怪的错误。文本在scrollIs kvkkTextView是UILabel还是UITextView之后出现?它应该是UILabel。它是UITextView。如何使用UILabel滚动?
private func updateGradientFrame() {
    gradient.frame = CGRect(
        x: 0,
        y: scrollView.contentOffset.y,
        width: scrollView.bounds.width,
        height: scrollView.bounds.height
        )
}