简体   繁体   English

在滑动时保持 TabBar 大标题 swift

[英]Keep TabBar Large Title on swipe swift

I have a UIViewController which holds a UITableView and also have a navigation bar with a large title.我有一个 UIViewController ,其中包含一个 UITableView 并且还有一个带有大标题的导航栏。 Whenever I scroll down through the table view, the large title disappears and becomes a small header.每当我向下滚动表格视图时,大标题就会消失并变成一个小 header。 How can I maintain the large title (make it static/sticky) when I scroll through.滚动浏览时如何保持大标题(使其成为静态/粘性)。

I added a picture of my screen before the swipe , in the middle of a swipe , and after the swipe.在刷卡之前、刷卡中间和刷卡之后添加了我的屏幕图片。

I want to maintain the large title seen in the before the swipe image even after the swipe occurs.即使在滑动发生之后,我也想保持在滑动图像之前看到的大标题。

The code I currently have in terms of the navigation bar (for the large header and transparency) is as follows我目前在导航栏方面的代码(对于大型 header 和透明度)如下

class OneChallengeViewController: UIViewController { 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



 }

The title will collapse on scroll as long as the root view is scrollable, ie is a scrollView or a view which embeds a UIScrollView .只要根视图是可滚动的,标题就会在滚动时折叠,即滚动视图或嵌入UIScrollView的视图。

To achieve what you want in the particular case you'd need to add a dummy view ahead of your tableView in the view hierarchy.要在特定情况下实现您想要的,您需要在视图层次结构中的tableView之前添加一个虚拟视图。

I've found your question while searching how to achieve the opposite我在搜索如何实现相反的目标时发现了您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM