1

I have subclassed UINavigationBar and customised the height of navigation-bar. Now it has 108pt height. But in all the screens, I am having the top area of tableview/scrollview behind the custom navigation-bar. I have tried extend edges under top bar, but it only move 64pt.

Is there any way to move all the contents below the custom navigation bar, without modifying top constraint or setting content insets of every screen?

krishnanunni
  • 510
  • 7
  • 16

2 Answers2

1

Did you try -

automaticallyadjustsscrollviewinsets = false

This can be done from storyboard as well as from code.

Also, try setting your navigation bar to opaque.

Hope this helps.

iOS Developer
  • 538
  • 4
  • 10
  • I have tried automaticallyAdjustScrollViewInset, but not opaque. But even after that change, issue still remains. We have the ViewController's view behind the navigation bar. – krishnanunni Feb 27 '18 at 06:39
0

First of all i would avoid to change the height of the apple navigationBar. This can cause some more problems. As you can see.

Anyway you could change the contentInset of the tableView.

tableView.contentInset = UIEdgeInsets(top: HEIGHTOFNAVIGATIONBAR - ADDEDHEIGHT, left: 0, bottom: 0, right: 0)
  • But this way, I will have to set this on all the screens(There are more than 30 screens). Isn't it supposed to alter the TopLayoutGuide of the screen according to the new navigation bar height? Apple is providing option to customise navigation bar. We can set our custom class as navigation controller's navigation bar. So this should not cause any problem(unfortunately it is causing problem). – krishnanunni Feb 27 '18 at 06:33
  • How do you change the size of the navigationBar? Do you override sizeThatFits? – Frederik Kaiser Feb 27 '18 at 06:43
  • I was overriding sizeThatFits in the past. But in iOS 11, it does't work. So I override setFrame and layoutSubViews – krishnanunni Feb 27 '18 at 06:45