У меня есть пользовательская панель UINavigationBar (другого размера, фона и т. Д.), Внутри которой есть настраиваемый вид заголовка. Я использовал этот код для достижения этой цели:
UIView * mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
mainView.backgroundColor = [UIColor yellowColor];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,kScreenWidth,80)];
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UINavigationItem *currentItem = [[UINavigationItem alloc] init];
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont fontWithName:@"Helvetica-Bold" size: 30.0];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor whiteColor]];
[label setText:self.title];
[label sizeToFit];
[currentItem setTitleView:label];
[label release];
[navBar pushNavigationItem:currentItem animated:NO];
[currentItem release];
[mainView addSubview:navBar];
[navBar release];
self.view = mainView;
[mainView release];
Однако теперь моя проблема в том, что даже если пользовательский вид заголовка добавлен правильно, он не центрируется по вертикали с помощью панели навигации. Что мне не хватает?
Спасибо!