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

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

问题描述

我想在我的应用程序中的UINavigationBar是完全透明的,并与直接在它下面的viewcontroller齐平。然而,我可以找到的唯一的代码,它使透明,但不透明。我知道这可以在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在注释中建议的,将bar设置为默认值:

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天全站免登陆