Reputation:
I have a custom UINavigationController which I Simply resize the height but I get no result:
actually my main code is this: ( this will get perfect height according tu device size )
class NavigationController1: UINavigationController {
let Theframe = UIScreen.main.bounds
override func awakeFromNib() {
self.navigationBar.frame = CGRect.init(x: self.navigationBar.frame.origin.x*Theframe.width/375, y: self.navigationBar.frame.origin.y*Theframe.height/667, width:self.navigationBar.frame.width*Theframe.width/375, height: self.navigationBar.frame.height*Theframe.height/667)
}
}
but the upper code for height isn't working neither.
Upvotes: 2
Views: 742
Reputation:
I solved the issue by putting in viewWillLayoutSubviews() final code:
import UIKit
class NavigationController1: UINavigationController {
let Theframe = UIScreen.main.bounds
override func viewWillLayoutSubviews() {
self.navigationBar.frame = CGRect.init(x: self.navigationBar.frame.origin.x, y: self.navigationBar.frame.origin.y, width:self.navigationBar.frame.width, height: 200)
}
}
Upvotes: 3
Reputation: 197
It could be override and redrawn because of the sIze inspector. Put the same requirements there so you can ensure its not overriding the custom code.
Upvotes: 0