0

I managed to increase the height of my navigation bar, but I faced with the problem, that title and buttons are situated in the bottom of navigator bar.

extension UINavigationBar {

    open override func sizeThatFits(_ size: CGSize) -> CGSize {
        let v = self.value(forKey: "frame") as? CGRect
        return v?.size ?? CGSize(width: UIScreen.main.bounds.width, height: 44)
    }

}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: 64)
}

enter image description here

I tried to set offset, using

navigationBar.setTitleVerticalPositionAdjustment(-10, for: .default)
navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.rightBarButtonItem?.setBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.rightBarButtonItem?.setBackButtonBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.leftBarButtonItem?.setBackButtonBackgroundVerticalPositionAdjustment(-10, for: .default)

Actually that setting only apply to my title, and the position of button bars remain the same.

But I don't think my solution is the best.

dand1
  • 371
  • 2
  • 8
  • 22
  • why don't you show how exactly did you increase the navigation bar height? – Fernando Mazzon Jun 02 '17 at 14:52
  • Couple links in the comments on this question may be helpful: https://stackoverflow.com/questions/44181264/move-navigationbars-left-and-right-barbuttonitems-vertically-upwards – DonMag Jun 02 '17 at 15:03

2 Answers2

1

Its not a good practice to increase the size of the navigation bar. Instead you can add a uiview right under navigation bar with same color and remove the navigation bar border to make to look like height increased. Here is an example how yelp does it. enter image description here

phamot
  • 384
  • 2
  • 12
0

I posted the solution of this problem in another thread. Hope this helps.

vertically aligning UINavigationItems

iGW
  • 633
  • 5
  • 14