Vinayak Bhor
Vinayak Bhor

Reputation: 691

Landscape view issue with navigation bar

Default Navigation bar height is 64.But after change it's orientation to landscape navigation bar height changed to 28.I want to set Fix navigation bar size in all orientation.

Upvotes: 2

Views: 975

Answers (1)

maxwell
maxwell

Reputation: 4166

You can add orientation observer:

NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)

And add rotate method:

func rotated() {
    let height: CGFloat = 50 //whatever height you want to add to the existing height
    let bounds = self.navigationController!.navigationBar.bounds
    self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}

Upvotes: 1

Related Questions