【发布时间】:2018-05-28 03:14:37
【问题描述】:
我曾尝试在滚动表格视图图像时显示和隐藏,但在这里我需要像当我开始滚动表格视图时搜索栏也需要转到顶部并隐藏,当我向下滚动搜索栏时需要随着表格视图滚动下来并固定在同一位置,谁能帮我实现这个?
这是我已经尝试在表格视图滚动时检测滚动的代码
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if(velocity.y>0) {
//Code will work without the animation block.I am using animation block incase if you want to set any delay to it.
UIView.animate(withDuration: 1.5, delay: 0, options: UIViewAnimationOptions(), animations: {
self.searchBar.isHidden = true
print("Hide")
}, completion: nil)
} else {
UIView.animate(withDuration: 1.5, delay: 0, options: UIViewAnimationOptions(), animations: {
self.searchBar.isHidden = false
print("Unhide")
}, completion: nil)
}
}
【问题讨论】:
标签: ios swift3 uiscrollview