我怎么能做一个
UIScrollView
开始从上到下滚动。当我刷(下)它将首先向下滚动而不是向上消失。我现在拥有的是,我可以先向上滚动然后向下滚动,同时向下滚动它就会消失。
这是我的密码-
func scrollViewDidScroll(_ scrollView: UIScrollView) {
//for toogle swipe view
if scrollView.contentOffset.y < 120 {
self.swipeMsgView.isHidden = false
}else {
self.swipeMsgView.isHidden = true
}
//for making bottom inset
if scrollView.contentOffset.y < 190 {
var contentInset:UIEdgeInsets = scrollView.contentInset
contentInset.bottom = scrollView.contentOffset.y-100
scrollView.contentInset = contentInset
}
//when swipe down
if scrollView.contentOffset.y == 0 {
if !isScrollDownFirstTime{
UIView.animate(withDuration: 0.5, animations: {
self.dismiss(animated: true, completion: nil)
})
}
}
//for tracking first time scrolling
if scrollView.contentOffset.y > 150 {
isScrollDownFirstTime = false
}
}
它工作得很好。但我想在用户先刷或向下滚动时消失视图(刷手势不起作用)。有没有什么优雅的方法来处理这个现有的功能?谢谢您。