Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>For UISearchBarStyleProminent:</strong></p> <p>1) Be sure to check the "Translucent" box for the search bar in the Attributes Inspector.</p> <p>2) Add the following to viewDidLoad:</p> <pre><code>self.navigationController.navigationBar.translucent = NO; // If you have a navBar self.searchDisplayController.searchBar.translucent = NO; </code></pre> <p><strong>Edit</strong> From <a href="https://stackoverflow.com/users/1306956/rudolf-adamkovic">@RudolfAdamkovic</a>:</p> <blockquote> <p>"I've found that for <code>UISearchBarStyleProminent</code>, executing [the following] helps. That way, you can keep it on in Storyboard."<br> <code>searchBar.translucent = YES;</code><br> <code>searchBar.translucent = NO;</code> </p> </blockquote> <p><strong>For UISearchBarStyleMinimal:</strong></p> <p>In order to get the minimal search bar to not be translucent I have put together a workaround.</p> <p>1) Be sure to check the "Translucent" box for the search bar in the Attributes Inspector.</p> <p>2) Add the following code to viewDidLoad:</p> <pre><code>self.navigationController.navigationBar.translucent = NO; self.searchDisplayController.searchBar.translucent = NO; self.searchDisplayController.searchBar.backgroundColor = [UIColor desiredColor]; </code></pre> <p>3) A UIView needs to be added to the viewController. This view needs to be 20px heigh and should have the same color as the searchBar.barTintColor.</p> <p><strong>Note:</strong> I think this workaround is needed because: <a href="https://developer.apple.com/library/iOS/documentation/UserExperience/Conceptual/UIKitUICatalog/UISearchBar.html#//apple_ref/doc/uid/TP40012857-UISearchBar" rel="nofollow noreferrer">"The style UISearchBarStyleMinimal provides no default background color or image but will display one if customized as such."</a> Thus the only way to get this functionality for UISearchBarStyleMinimal is to set the backgroundColor. </p> <p>See UISearchBar <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/Reference.html#//apple_ref/occ/instp/UISearchBar/translucent" rel="nofollow noreferrer">documentation</a> for more details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload