问题
Simple question: How can I increase the height of the navigation bar so that additional widgets will fit in there while keeping the blur?
Examples are the Calendar app where weekday abbreviations are added to the bottom of the navigation bar...
...and in Mail when you move the mail to a different folder:
回答1:
As iAnurag post ans is correct but still have some ui problem (Width is not proper)
You can change size by adding category like below
Sample Project
Download
Code
#import "ViewController.h"
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
CGRect rec = self.frame;
CGRect screenRect = [[UIScreen mainScreen] bounds];
rec.size.width = screenRect.size.width;
rec.size.height = 70;
return rec.size;
}
@end
Output
When press on "Button"
Problem in iAnurag Code
回答2:
https://developer.apple.com/library/prerelease/content/samplecode/NavBar/Introduction/Intro.html
From ReadMe.md:
Extended Navigation Bar #### This example demonstrates placing a custom view underneath the navigation bar in such a manner that viewappears to be part of the navigation bar itself. This technique may be used to create an interface similar to the iOS Calendar app.
My not humble opinion: Don't override sizeThatFits(_:), don't set constraints on nav bar height. Just do the illusion from example above.
回答3:
Create a UINavigationBar Category with a custom sizeThatFits.
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize newSize = CGSizeMake(self.frame.size.width,70);
return newSize;
}
@end
来源:https://stackoverflow.com/questions/27328136/how-to-increase-the-height-of-uinavigationbar