如何在IOS 8中使UINavigationBar透明?

前端之家收集整理的这篇文章主要介绍了如何在IOS 8中使UINavigationBar透明?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经尝试了很多让UINavigationBar透明的东西.但我没有成功.我设置的图像是透明的.这是我的代码.
有帮助吗?
提前致谢.
  1. [rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault];
  2. rootNavC.navigationBar.translucent = YES;
  3. rootNavC.navigationBar.backgroundColor = [UIColor clearColor];
  4. [[UINavigationBar appearance] setTitleTextAttributes:@{
  5. UITextAttributeTextColor : [UIColor whiteColor],UITextAttributeTextShadowColor : [UIColor clearColor],UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0,0)],UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20]
  6. }];

解决方法

试试这个
  1. [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
  2. forBarMetrics:UIBarMetricsDefault];
  3. self.navigationController.navigationBar.shadowImage = [UIImage new];
  4. self.navigationController.navigationBar.translucent = YES;
  5. self.navigationController.view.backgroundColor = [UIColor clearColor];

我希望上面的代码有所帮助.

猜你在找的iOS相关文章