【问题标题】:How to control title font in UINavigationBar title如何控制 UINavigationBar 标题中的标题字体
【发布时间】:2012-10-01 16:14:07
【问题描述】:

我有导航栏控制器,我想在其中显示文本。但是每次的文字都不一样。最少 5 个字符,最多 60 个字符。我希望所有角色都可见。如何设置 UINavigation Bar 标题的最小和最大字体大小?

感谢

【问题讨论】:

  • 奇怪的问题被否决了。
  • 同意。也许是连续的句子。我们在这里主要关注人工语言的语法。我已经编辑了你的 q。并投票赞成。

标签: iphone objective-c ios uinavigationcontroller title


【解决方案1】:

这就是答案

UILabel *bigLabel = [[UILabel alloc] init];
bigLabel.text = @"1111111122222233333344444455555556666777888899999000000";
bigLabel.backgroundColor = [UIColor clearColor];
bigLabel.textColor = [UIColor whiteColor];
bigLabel.font = [UIFont boldSystemFontOfSize:20];
bigLabel.adjustsFontSizeToFitWidth = YES;
[bigLabel sizeToFit];

self.navigationItem.titleView = bigLabel;

【讨论】:

    【解决方案2】:

    您需要在 UINavigationBar 上设置 titleView。您可以使用任何正常的 UILabel 设置将其设置为 UILabel。

    【讨论】:

      猜你喜欢
      • 2015-10-04
      • 2012-05-25
      • 1970-01-01
      • 2014-07-06
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多