[英]Navigation bar shrinks when pushed to the new view controller
我有一个详细视图 controller,它有显示用户信息的tableView
。 但是,当我从另一个视图 controller 推到详细视图 controller 时,导航栏总是会缩小,即使我强制成为大标题而不是在其他任何地方设置它。 如果我向下滚动,它会显示为一个大标题。 你以前遇到过这样的问题吗?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationItem.largeTitleDisplayMode = .always
navigationController?.navigationBar.prefersLargeTitles = true
}
注:版本,iOS 14.2
您需要设置外观。
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor(named: "menuNavBarTitle") ?? .red]
navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor(named: "menuNavBarTitle") ?? .red]
navBarAppearance.backgroundColor = .systemBackground
navigationController?.navigationBar.standardAppearance = navBarAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
self.navigationController?.navigationBar.prefersLargeTitles = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.