如何删除UINavigationBar和UISearchBar发际线 [英] How to remove UINavigationBar and UISearchBar hairline

查看:79
本文介绍了如何删除UINavigationBar和UISearchBar发际线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个iOS 7应用程序,我希望在NavigationBar下方有一个SearchBar,我希望它们看起来像一个单件。因此,我需要使用相同的颜色(已经完成)对它们进行着色并删除NavigationBar底部和SearchBar顶部的发际线。我怎样才能实现呢?

I am creating an iOS 7 app in which I'd like to have a SearchBar right bellow the NavigationBar, and I wanted them both to look like a single piece. Therefore I need to tint them with the same color (done already) and remove that hairline at the bottom of the NavigationBar and at the top of the SearchBar. How can I achieve that?

推荐答案

官方说明,这只能通过设置 shadowImage 为空图像。但是,仔细看看文档,据说:

Officially, this is only possible by setting the shadowImage of the navigationBar to an empty image. However, a closer look at the documentation, it is said:


要显示自定义阴影图像,还必须自定义背景图像使用setBackgroundImage:forBarMetrics:方法设置。如果使用默认背景图像,则无论此属性的值如何,都将使用默认阴影图像。

For a custom shadow image to be shown, a custom background image must also be set with the setBackgroundImage:forBarMetrics: method. If the default background image is used, then the default shadow image will be used regardless of the value of this property.

使用自定义背景图片,你将失去模糊的背景半透明。

By using a custom background image, you would lose the blurred background translucency.

如果你觉得冒险,发际线是一个UIImageView,它是导航栏的子视图。您可以找到它并将其设置为隐藏。例如,这就是Apple在其原生日历应用中所做的事情。记得在当前视图消失时显示它。

If you feel adventurous, the "hairline" is a UIImageView that is a subview of the navigation bar. You can find it and set it as hidden. This is what Apple does in their native calendar app, for example. Remember to show it when the current view disappears.

这篇关于如何删除UINavigationBar和UISearchBar发际线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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