gpt4 book ai didi

swift - 向上或向下滚动时增加或减少 imageView 的高度

转载 作者:行者123 更新时间:2023-11-30 10:43:37 25 4
gpt4 key购买 nike

向上或向下滚动时增加或减少imageView的高度

extension DetailViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {


if (self.lastContentOffset > scrollView.contentOffset.y) {
UIView.animate(withDuration: 0.2, animations: {
print("going down")
if self.imgViewHeight.constant >= 200 {
self.blurView.alpha = 0

self.backButton.isHidden = false
}
else if self.imgViewHeight.constant <= 200{
self.blurView.alpha = 1


self.imgViewHeight.constant = self.imgViewHeight.constant + 4

}
}, completion: nil)

}
else if (self.lastContentOffset < scrollView.contentOffset.y) {

UIView.animate(withDuration: 0.2, animations: {
if self.imgViewHeight.constant <= 72 {
self.blurView.alpha = 1
self.backButton.isHidden = false
self.descriptions.isScrollEnabled = true
}
else if self.imgViewHeight.constant >= 72{
self.blurView.alpha = 1

self.imgViewHeight.constant = self.imgViewHeight.constant - 4

}

print("lolol:\(self.imgViewHeight.constant)")

}, completion: nil)

}
else {

}

self.lastContentOffset = scrollView.contentOffset.y
}
}

最佳答案

您可以使用 ScrollView 函数,例如:

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
//your code when you want start scrolling

}

func scrollViewWillEndDragging(_ scrollView: UIScrollView) {
//your code when you want run after stop scrolling

}

关于swift - 向上或向下滚动时增加或减少 imageView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56287511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com