iOS 13 导航栏大标题问题

Giz*_*odo 3 xcode uinavigationbar ios swift uinavigationbarappearance

我试图Title在 a 中显示一个大的Navigation bar,但背景清晰。向上滚动时,它将Navigation bar具有模糊效果。

在此处输入图片说明

在此处输入图片说明

这看起来是正确的,但是,在滚动时,动画似乎被破坏了。此外,过渡有时会卡住:

在此处输入图片说明

在此处输入图片说明

我的代码如下:

UINavigationController

override func viewDidLoad() {
   super.viewDidLoad()

   if #available(iOS 13.0, *) {

      self.navigationBar.prefersLargeTitles = true

      let style = UINavigationBarAppearance()
      style.configureWithDefaultBackground()

      style.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 18)]

      self.navigationBar.standardAppearance = style
      self.navigationBar.compactAppearance = style


      //Configure Large Style
      let largeStyle = UINavigationBarAppearance()
      largeStyle.configureWithTransparentBackground()

      largeStyle.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 28)]

      self.navigationBar.scrollEdgeAppearance = largeStyle

   }
}
Run Code Online (Sandbox Code Playgroud)

UITableView是内部的UINavigationController。两者都是通过 segue 方式从故事板中提取的。

Man*_*dan 5

您可以尝试使用 UITableViewController 代替 UITableview。我试过使用 UITableViewController 并且它对我来说工作正常。请检查以下设计和代码。

在此处输入图片说明

class ViewController: UITableViewController
{
    override func viewDidLoad() {
        super.viewDidLoad()
          if #available(iOS 13.0, *) {
                  self.navigationController?.navigationBar.prefersLargeTitles = true
                  let style = UINavigationBarAppearance()
                  style.configureWithDefaultBackground()
                  style.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 18)]
                  self.navigationController?.navigationBar.standardAppearance = style
                  self.navigationController?.navigationBar.compactAppearance = style
                  //Configure Large Style
                  let largeStyle = UINavigationBarAppearance()
                  largeStyle.configureWithTransparentBackground()
                  largeStyle.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 28)]
                  self.navigationController?.navigationBar.scrollEdgeAppearance = largeStyle
              }
        self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
        // Do any additional setup after loading the view.
    }

    override func numberOfSections(in tableView: UITableView) -> Int {
        1
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        10
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = "\(indexPath.row)"
        return cell
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:-

在此处输入图片说明