-
-
Save maciekish/c2c903d9b7e7b583b4b2 to your computer and use it in GitHub Desktop.
This is AWESOME. Thank you!
Thank you!
Or you could subclass the UINavigationBar
class and override the sizeThatFits:
method there. Just return the value you want there. It is a more elegant solution (imo) than using categories if you need a static height. (and one that works on Swift!)
[self.superview setNeedsUpdateConstraints];
Hi, I found out that there is a problem when you have your navigation controllers in storyboard. The main issue is that the width of your navigation bar is not stretched to whole width of screen. It looks like that method
newSize = [super sizeThatFits:size]; returns wrong width. I've added line of code that fixes this problem.
newSize.width = self.window.bounds.size.width; // just get the width from different source...
The whole size that fits method with small fix:
-
(CGSize)sizeThatFits:(CGSize)size
{
CGSize newSize;if (self.height) {
newSize = CGSizeMake(self.superview.bounds.size.width, [self.height floatValue]);
} else {
newSize = [super sizeThatFits:size];
newSize.width = self.window.bounds.size.width;
}return newSize;
}
Enjoy :)
How do you use it to avoid that the navigation bar height changes visibly when the view appears? I call setHeight in the viewDidLoad but now I see it jumping.