네비게이션 바 자체에 폰트를 지정하거나 글씨의 크기를 지정하는 방법이 있는 것 같지는 않다.
하지만 여러가지 방법을 이용해서 폰트의 지정 및 글씨의 크기를 변경해 사용할 수 있다.
직접 사용해본 코드로 잘 동작하는 것을 확인할 수 있었다.
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont fontWithName:@"Helvetica-Bold" size: 15.0];
// Optional - label.text = @"NavLabel";
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor whiteColor]];
[label setText:@"원하는 타이틀을 지정하세요."];
[label sizeToFit];
[self.navigationController.navigationBar.topItem setTitleView:label];
[label release];
또 아래와 같이 하면 메인 타이틀 하위에 subtitle 을 넣는 효과까지 낼 수 있다.
( 사실 레이블을 두개 붙이는 것이지만..)
- (void)SetNavigationTitle:(NSString*)title subtitle:(NSString*)subTitle
{
if (subtitle == nil) {
self.navigationItem.titleView = nil;
self.navigationItem.title = title;
return;
}
// set the default title anyway, so the next view controllers will have the correct text on their "back" button
self.navigationItem.title = title;
#define LEFT_OFFSET 15
// Replace titleView
CGRect headerTitleSubtitleFrame = CGRectMake(LEFT_OFFSET, 0, 200, 44);
UIView* _headerTitleSubtitleView = [[UILabel alloc] initWithFrame:headerTitleSubtitleFrame];
_headerTitleSubtitleView.backgroundColor = [UIColor clearColor];
_headerTitleSubtitleView.autoresizesSubviews = YES;
CGRect titleFrame = CGRectMake(LEFT_OFFSET, 2, 160, 24);
UILabel *titleView = [[UILabel alloc] initWithFrame:titleFrame];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20];
titleView.textAlignment = UITextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0, -1);
titleView.text = title;
titleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:titleView];
[titleView release];
CGRect subtitleFrame = CGRectMake(LEFT_OFFSET, 24, 160, 44-24);
UILabel *subtitleView = [[UILabel alloc] initWithFrame:subtitleFrame];
subtitleView.backgroundColor = [UIColor clearColor];
subtitleView.font = [UIFont boldSystemFontOfSize:13];
subtitleView.textAlignment = UITextAlignmentCenter;
subtitleView.textColor = [UIColor whiteColor];
subtitleView.shadowColor = [UIColor darkGrayColor];
subtitleView.shadowOffset = CGSizeMake(0, -1);
subtitleView.text = subTitle;
subtitleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:subtitleView];
[subtitleView release];
self.navigationItem.titleView = _headerTitleSubtitleView;
[_headerTitleSubtitleView release];
}
[출처] NavigationBar 의 글씨 크기 변경하기..|작성자 홍길동