【问题标题】:Setting the height of the UINavigationBar设置 UINavigationBar 的高度
【发布时间】:2013-04-27 15:42:31
【问题描述】:

我已将UINavigationBar 背景图像设置为高度为68px 的图像,而不是默认的44px。现在图像显示正常,但UINavigationController 中的内容与标题图像重叠在第一个(68-44)px = 12px 中。

我该如何解决这个问题?我试过设置UINavigationBarframe 没有运气。

谢谢,卡斯帕。

这是我的代码(AppDelegate.m):

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.frontTableViewController];
UINavigationBar *navBar = navigationController.navigationBar;
[navBar setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault];
self.window.rootViewController = navigationController;

【问题讨论】:

  • 截图对了解您的问题有很大帮助
  • 请同时编写用于设置 UINavigation 栏图像的代码
  • @Bonnie 你去!

标签: xcode cocoa-touch uinavigationcontroller uinavigationbar


【解决方案1】:

尝试以这种方式设置导航栏的图像

self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myNavBarImage.png"]];

或者看看这个Answer

【讨论】:

  • 这只会设置特定 navigationItem 的标题图像 - 我希望导航栏是静态图像(高度大于 44 像素),同时仍具有 UINavigationBar 功能
  • 试试答案中的链接
  • 我在该链接中找到了解决方案。解决方案是将sizeThatFits 重新定义为链接中的那种。
猜你喜欢
  • 2011-01-09
  • 2021-10-12
  • 2018-01-24
  • 1970-01-01
  • 2010-11-26
  • 2016-02-03
  • 2018-09-30
  • 2010-10-28
相关资源
最近更新 更多