How to remove UINavigationBar and UISearchBar hairline

前端 未结 5 1042
执念已碎
执念已碎 2020-12-15 14:33

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 tin

5条回答
  •  青春惊慌失措
    2020-12-15 14:52

    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:

    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.

    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.

提交回复
热议问题