简体   繁体   English

iOS 7中的半透明导航栏

[英]Translucent Navigation Bar in iOS 7

I have been trying to figure this out all day. 我一直在努力解决这一问题。 How do I change the transparency level for the UINavigationBar on iOS 7? 如何在iOS 7上更改UINavigationBar的透明度级别?

This is what I have tried (with no success): 这是我尝试过的( 没有成功):

  • Setting the UINavigationBar tint colour to have transparency: [self.navigationController.navigationBar setTintColor:[UIColor colorWithWhite:1 alpha:0.01f]] . 设置UINavigationBar色调颜色具有透明度: [self.navigationController.navigationBar setTintColor:[UIColor colorWithWhite:1 alpha:0.01f]] This works, but the image as the background for my UIViewController appears to be grayscale. 这可行,但是作为UIViewController背景的图像似乎是灰度的。
  • Setting the alpha of both the UINavigationBar and the CALayer for the UINavigationBar. 设置UINavigationBar和UINavigationBar的CALayer的alpha。

Thank you very much. 非常感谢你。

Edit: I am trying to achieve something like this . 编辑:我正在尝试实现这样的目标

I don't believe it to be possible to make the bar opaque anymore. 我认为不再有可能使该条变得不透明。 The link you added does not have an opaque bar either. 您添加的链接也没有不透明的栏。 It is translucent with what looks to be a blue barTintColor. 它看起来像蓝色的barTintColor是半透明的。

What I suspect you are trying to do is have your content not covered by the translucent bar. 我怀疑您要尝试做的是使您的内容不被半透明的条覆盖。 In that case, look at UIViewController edgesForExtendedLayout . 在这种情况下,请查看UIViewController edgesForExtendedLayout You probably want self.edgesForExtendedLayout = UIRectEdgeNone; 您可能需要self.edgesForExtendedLayout = UIRectEdgeNone; .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM