所有UINavigation条标题的大写字符串

p0l*_*ris 11 objective-c ios uiappearance

目前,我正在使用以下内容更改导航栏的字体AppDelegate:

[[UINavigationBar appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIFont fontWithName:@"..." size:...], NSFontAttributeName,
  nil]];
Run Code Online (Sandbox Code Playgroud)

有没有办法做同样的事情来确保字符串全局大写?

xi.*_*lin -1

您可以创建一个底座UIViewController来隐藏原来的导航栏,然后自己添加一个新的。

self.navigationController.navigationBarHidden = YES;

UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:frame];
UINavigationItem *naviItem = [[UINavigationItem alloc] init];
self.titleLabel = [UILabel new];
naviItem.titleView = self.titleLabel;
navigationBar.items = [NSArray arrayWithObjects:naviItem, nil];
[self.view addSubview:navigationBar];
Run Code Online (Sandbox Code Playgroud)

然后你可以控制titleLabel的标题设置。