ios - 如何在 IOS 8 中使 UINavigationBar 透明?

标签 ios iphone

我已经做了很多尝试来使 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]
 }];

最佳答案

试试这个

   [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.view.backgroundColor = [UIColor clearColor];

希望以上代码对您有所帮助。

关于ios - 如何在 IOS 8 中使 UINavigationBar 透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27228317/

相关文章:

ios - 当只有一个字典可用时,如何通过一个或多个字典访问for循环中的局部变量?

ios - 每周特定日期的 NSDate 扩展

ios - iPhone 在后台收集 CoreMotion 数据。 (超过10分钟)

ios - NSURLSessionConfiguration 的 timeoutIntervalForRequest 不适用于后台 URLSession

ios - cacheAsBitmap 对 AIR for iOS 中使用 scrollRect mask 的 Sprite 没有影响

ios - 在应用程序更新中停止对armv7s的支持

iphone - ccp 和 cpv - cocoa 的功能差异和完整形式

iPhone - 固定(tableHeaderView)在滚动单元格时使用分组的 UITableView

ios - 使用 Storyboard在 UItableview 上 float 按钮

ios - 当应用程序进入前台但不知道在 swift 4 中关闭此 View Controller 时显示 View Controller