如何在iOS 8中使UINavigationBar透明?

Mounika Vangala

我做了很多尝试,使UINavigationBar透明。但是我这样做失败了。我设置的图像是透明的。这是我的代码。有什么帮助吗?提前致谢。

 [rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault];
rootNavC.navigationBar.translucent = YES;
rootNavC.navigationBar.backgroundColor = [UIColor clearColor];
[[UINavigationBar appearance] setTitleTextAttributes:@{
                           UITextAttributeTextColor : [UIColor whiteColor],
                     UITextAttributeTextShadowColor : [UIColor clearColor],
                    UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20]
 }];
Mounika Vangala

谢谢大家 问题是我在视图控制器中添加了以下行:

if (IS_OS_7_OR_LATER)
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

这就是为什么代码无法正常工作的原因。当我删除线

self.edgesForExtendedLayout = UIRectEdgeNone;

该代码有效。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章