UINavigationBar transparent + on top of UITableView

时间:2018-02-01 18:28:35

标签: ios swift

I have a transparent UINavigationBar. I also set hidesBarsOnSwipe to true. I want my navigationBar be on top of the content and hides when scrolling. Basically i want to achieve this effect (Navigation Bar on top of the content and also hiddes when scroll):

enter image description here

For now i just have this code and works everything, but i'm not able to put the content of the view behind the navigationBar:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.backgroundColor = .clear
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.hidesBarsOnSwipe = true

enter image description here

Here is a sample project , as you see the tableView is at the bottom of the navigationBar and just goes to the top when it hides the navigationBar.

2 个答案:

答案 0 :(得分:0)

On your view controller in Interface Builder disable Adjust Scroll View Insets. You can probably do it from code if you want as well.

答案 1 :(得分:-1)