我正在尝试在导航项目标题视图中放置标签。如果是长标题,则在推/弹到其他屏幕时,标签从其原始位置移动并发生转换 设置标签的代码:
- (void)setNavBarTitle:(NSString *)title {
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 60.0)];
label.font=[UIFont boldSystemFontOfSize:20.0];
[label setBackgroundColor:[UIColor clearColor]];
[label setNumberOfLines:0];
[label setTextColor:[UIColor whiteColor]];
[label setTextAlignment:NSTextAlignmentCenter];
[label setText:title];
[label sizeToFit];
self.navigationItem.titleView = label;
self.parentViewController.navigationItem.titleView = label;
}