I have a navigation bar added programatically to the view with VFL (visual format language)
like this
navBar.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(navBar)
let views = ["bar": navBar]
var constraints = [NSLayoutConstraint]()
constraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|[bar]|", options: [], metrics: nil, views:views)
constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|[bar(64)]", options: [], metrics: nil, views:views)
NSLayoutConstraint.activate(constraints)
the above code works fine but gives a constant height to the navigation bar as 64. but I would like to have it based on the mobile's orientation, portrait-64 and landscape-44
If you want to change height depending on orientation change you need to grab when orientation change
Below method will help you do this.So change your layout depending on orientation in this method too.
Swift 3 version: