简体   繁体   English

Swift-使用tableView进行大标题转换

[英]Swift - Large title transition with tableView

I'm trying to code the "Sign up" part of my app. 我正在尝试对应用程序的“注册”部分进行编码。 I'm using Large Title for that. 我正在为此使用大标题。 If I use normal ViewControllers, everything is good, but if I use TableViewController, I have a really bad transition when I change the ViewController: 如果我使用普通的ViewControllers,一切都会很好,但是如果我使用TableViewController,则在更改ViewController时会有非常糟糕的过渡:

在此处输入图片说明

I can see a black background. 我可以看到黑色背景。 Do you have any idea about how I could correct this? 您是否知道我该如何纠正?

EDIT: If I set isTranslucent = true, it's okay, but I would like to have a white NavigationBar. 编辑:如果我将isTranslucent = true设置为可以,但是我希望有一个白色的NavigationBar。 Do you know how to do that? 你知道怎么做吗?

override func viewDidLoad(){
   super.viewDidLoad()
   if #available(iOS 11.0, *) {
         // tableView.contentInsetAdjustmentBehavior = .never
         self.navigationController?.navigationBar.prefersLargeTitles = true
      }
      self.navigationController?.navigationBar.isTranslucent = false

      self.navigationController?.navigationBar.shadowImage = UIImage()
}

@IBAction func continueAction(_ sender: Any) {
      let signupSecondVC = self.storyboard?.instantiateViewController(withIdentifier: "SignupSecondViewController") as! SignupSecondViewController
      self.navigationController?.pushViewController(signupSecondVC, animated: true)
}

EDIT 2: 编辑2:

let img = UIImage(named: "backgroundNav")
navigationController?.navigationBar.setBackgroundImage(img, for: .default)

The NavigationBar is still translucent, even if the imageBackground is opaque ... 即使imageBackground不透明,NavigationBar仍是半透明的。

在此处输入图片说明

将导航栏的isTranslucent设置为true并通过它的backgroundImage来控制其颜色。

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

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