Posted image IIS 11-style UISearchBar

I would like to transfer my search bar tableHeaderViewto a new approach to seamless search bar in iOS 11 by customizing navigationItem.searchController.

Since my navigation bar uses a custom background image, I am wondering how to apply the same background image to the search bar. I tried

[navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBarPromptBackground"] forBarMetrics:UIBarMetricsDefaultPrompt];
[searchBar setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

to no avail. The search bar contains a standard navigation bar (if used barTintColor), but does not display a custom background image.

+4
source share
2 answers

UISearchBar , UINavigationItem. , , iOS 11. , , searchBar , - . , , .

, :

[[searchBar.heightAnchor constraintEqualToConstant:44.0] setActive:YES];
+3

, IOS11 . , , , IOS10:

[searchBarSearch setBackgroundImage:image];
[searchBarSearch setScopeBarBackgroundImage:image];

, .plist

View controller-based status bar appearance = NO

, , IOS11.

, !

+1

Source: https://habr.com/ru/post/1680804/


All Articles