【问题标题】:Navigationbar background image not fill navigationbar Objective-C导航栏背景图像不填充导航栏Objective-C
【发布时间】:2016-01-08 06:05:54
【问题描述】:

我需要将背景图片添加到导航栏,我完成了代码,但它显示在状态栏下方。如何在导航栏上完全显示图像。(iOS 8)。

实际上我需要实现的是如下图

我用于导航栏背景图片的代码是

UIImage *navBarBackgroundImage = [UIImage imageNamed:@"NavigationBarImg"];
[[UINavigationBar appearance] setBackgroundImage:navBarBackgroundImage forBarMetrics:UIBarMetricsDefault];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

【问题讨论】:

  • 你的图片尺寸是多少
  • 使用320x64的图片尺寸
  • 是的,它奏效了。谢谢

标签: objective-c uinavigationcontroller uinavigationbar ios9.1 xcode7.1


【解决方案1】:

使 UINavigationBar 透明

[self.navigationBar setBackgroundImage:[UIImage new]
                     forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    相关资源
    最近更新 更多