1

使用故事板创建导航栏。现在在 ios 7 中,我面临着增加导航栏高度的挑战。

UINavigationBar *navBar = [[self navigationController] navigationBar];

[navBar setFrame:CGRectMake(0, 100, 1024, 200)];
4

3 回答 3

2
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;
于 2013-10-29T07:52:18.637 回答
0

您无法更改导航栏的高度。它固定在 44 像素。

于 2013-10-29T08:17:03.733 回答
0

用这个 -

@implementation UINavigationBar (customNavBar)
- (CGSize)sizeThatFits:(CGSize)size
{
    CGSize navSize = CGSizeMake(self.frame.size.width,200);
    return navSize;
}
于 2014-12-08T10:10:43.387 回答