如何在 iOS 7 中制作完全透明的导航栏 [英] How to make completely transparent navigation bar in iOS 7

查看:20
本文介绍了如何在 iOS 7 中制作完全透明的导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的应用程序中的 UINavigationBar 完全透明并与它正下方的视图控制器齐平.但是,我能找到的唯一代码使它半透明但不透明.我知道这可以在 iOS 7 中完成,因为它用于笔记应用程序.我的问题是,他们用来做这件事的代码是什么?

I want the UINavigationBar in my app to be completely transparent and flush with the viewcontroller directly under it. However, the only code I could find makes it translucent but not transparent. I know this can be done in iOS 7 because it is used in the notes app. My question is, what is the code they used to do it?

推荐答案

来自 这个答案

[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];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

此外,正如 Josh 在评论中所建议的,将栏恢复为默认值:

Also, as suggested by Josh in the comments, to put the bar back to default:

[self.navigationController.navigationBar setBackgroundImage:nil
                     forBarMetrics:UIBarMetricsDefault];

这篇关于如何在 iOS 7 中制作完全透明的导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆