使用故事板创建导航栏。现在在 ios 7 中,我面临着增加导航栏高度的挑战。
UINavigationBar *navBar = [[self navigationController] navigationBar];
[navBar setFrame:CGRectMake(0, 100, 1024, 200)];
使用故事板创建导航栏。现在在 ios 7 中,我面临着增加导航栏高度的挑战。
UINavigationBar *navBar = [[self navigationController] navigationBar];
[navBar setFrame:CGRectMake(0, 100, 1024, 200)];
UIFont *font = [UIFont fontWithName:@"fontName" size:YourFloatSize];
CGSize titleSize = [title sizeWithFont:font];
UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, titleSize.width, titleSize.height)];
titleLable.text = title;
titleLable.textAlignment = NSTextAlignmentCenter;
titleLable.backgroundColor = [UIColor clearColor];
titleLable.textColor = [UIColor anyColorYouWant];
titleLable.font = font;
self.navigationItem.titleView = titleLable;
您无法更改导航栏的高度。它固定在 44 像素。
用这个 -
@implementation UINavigationBar (customNavBar)
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize navSize = CGSizeMake(self.frame.size.width,200);
return navSize;
}