How to remove UINavigationBar and UISearchBar hairline

前端 未结 5 1040
执念已碎
执念已碎 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:43

    One way to remove the hairline on the top and bottom of a UISearchBar is to replace the background image with a stretchable one, that does not have that thin border. Simply make a square shaped png with the color of your choice, then:

    [searchBar setBackgroundImage:[[UIImage imageNamed:@"SearchBarImage"] resizableImageWithCapInsets:UIEdgeInsetsMake( 10, 10, 10, 10)]];
    

    Since the background is solid you can use pretty much whatever values you want for the insets.

提交回复
热议问题