如何在IOS 8中使UINavigationBar透明? [英] How to make UINavigationBar Transparent in IOS 8?
本文介绍了如何在IOS 8中使UINavigationBar透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试了很多让UINavigationBar变得透明。但是我做错了。我设置的图像是透明的。这是我的代码。
有什么帮助吗?
提前致谢。
I have tried a lot to make UINavigationBar transparent. But I failed making it so.The image which I set was transparent. Here is my code . Any help ? Thanks in advance.
[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]
}];
推荐答案
谢谢大家。问题是我在视图控制器中添加了这一行:
Thanks all. The thing is that I am adding this line in my view controller:
if (IS_OS_7_OR_LATER)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
}
这就是代码无效的原因。当我删除该行
that is why the code is not working. When I remove the line
self.edgesForExtendedLayout = UIRectEdgeNone;
代码有效。
这篇关于如何在IOS 8中使UINavigationBar透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文