【问题标题】:Add image between status bar and navigation bar在状态栏和导航栏之间添加图片
【发布时间】:2014-03-29 04:19:56
【问题描述】:

我正在尝试在 IOS 的状态栏和导航栏之间添加图像。这可能吗?您能指导我如何实现这一目标吗?

基本上我正在尝试实现这样的目标:

【问题讨论】:

    标签: ios iphone objective-c uinavigationbar statusbar


    【解决方案1】:

    完全不知道,有没有可能?但我有这样的想法, 您需要为此创建自定义导航栏,您需要在创建时隐藏 rootView 控制器的导航栏。
    前 -

    self.rootNavigationController.navigationBarHidden = YES;
    

    然后首先使用UIImageView 添加您的自定义图像,并使用它的特定大小,然后添加您的自定义UINavigationBar (它是UIImageView/UIView 或其他) 2 个按钮。

    【讨论】:

      【解决方案2】:

      您可以使用 UIImageView 并按以下方式设置其图像

      - (void) viewDidLoad {
      
           topImage = [[UIIImageView alloc] initWithFrame:CGRctZero];
           topImage.image = [UIImage imageNamed:@"topim"];
           [self.view addSubview:topImage];
      
           // Add your UINavigationController here (or in Interface builder)
      }
      
      - (void) viewWillLayoutSubviews {
      
           topImage.frame = CGRectMake(0, 0, 320, 20);
           navController.view.frame = CGRectMake(0, 20, 320, self.view.bounds.size.height - 20);
      
      }
      

      【讨论】: