【发布时间】:2019-04-25 21:08:25
【问题描述】:
这是我的观点截图:
现在当用户向上滚动时,我需要隐藏这个 searchBar。当用户向下滚动时,我需要显示这个 searchBar。而且它应该是循序渐进的,而不仅仅是显示和隐藏。
这是我现在在viewDidLoad中的代码:
self.searchBar.frame = CGRect(x: 0, y: 0, width: (navigationController?.view.bounds.size.width)!, height: 55)
self.searchBar.barStyle = .default
self.searchBar.isTranslucent = false
self.searchBar.barTintColor = UIColor.groupTableViewBackground
self.searchBar.backgroundImage = UIImage()
self.searchBar.delegate = self
self.view.addSubview(searchBar)
self.definesPresentationContext = true
另外,我将tableView到顶部的距离设置为55,这样searchBar就不会覆盖tableView。
我该怎么办?
谢谢!
【问题讨论】: