滑动时保持 TabBar 大标题 swift

Keep TabBar Large Title on swipe swift

我有一个 UIViewController,它包含一个 UITableView,还有一个带有大标题的导航栏。每当我向下滚动 table 视图时,大标题就会消失并变成小 header。滚动浏览时如何保持大标题(使其成为static/sticky)。

我添加了我的屏幕图片before the swipe, in the middle of a swipe, and after the swipe.

即使在滑动发生后,我也希望在 before the swipe 图像中看到大标题。

我目前在导航栏(大header和透明度)方面的代码如下

class OneChallengeViewController: UIViewController {

@IBOutlet weak var tableView: UITableView!
let productCellId = "TableViewCell1TableViewCell"
var products = [ProductDto]()

override func viewDidLoad() {
 super.viewDidLoad()
 
 
 navigationController?.navigationBar.prefersLargeTitles = true
 navigationItem.title = "Challenges"
 navigationController?.navigationBar.barStyle = .default
 navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
 navigationController?.navigationItem.largeTitleDisplayMode = .always



 }

只要根视图是可滚动的,即滚动视图或嵌入 UIScrollView.

的视图,标题就会在滚动时折叠

要在特定情况下实现您想要的效果,您需要在视图层次结构中的 tableView 之前添加一个虚拟视图。

我在搜索如何实现相反结果时发现了你的问题