SearchController Searchbar背景颜色属性在ios Objective-C中也更改了导航条颜色

时间:2019-01-01 13:34:38

标签: ios objective-c uinavigationcontroller uisearchbar uisearchcontroller

请检查我是否尝试过,但这会更改整个颜色,但不会更改搜索栏背景。

1. try with navigation searchcontroller searchbar
2. my uisearchcontroller searchbar 
1.
     if (@available(iOS 11.0, *)) {
          self.navigationItem.searchController=nil;
          self.navigationItem.searchController.searchBar.backgroundColor=nil;
          self.navigationItem.searchController.searchBar.barTintColor=nil;
          self.navigationItem.searchController = self.searchControllerInvoice;
          [self.searchControllerInvoice.searchBar setBackgroundColor:UIColor.redColor];
          [self.searchControllerInvoice.searchBar setBarTintColor:UIColor.yellowColor];
          [self.searchControllerInvoice.searchBar setTintColor:UIColor.greenColor];
     } else {
          self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
     }
     OR
2.
     if (@available(iOS 11.0, *)) {
          self.navigationItem.searchController=nil;
          self.navigationItem.searchController.searchBar.backgroundColor=nil;
          self.navigationItem.searchController.searchBar.barTintColor=nil;
          self.navigationItem.searchController = self.searchControllerInvoice;
          [self.navigationItem.searchController.searchBar setBackgroundColor:UIColor.redColor];
          [self.navigationItem.searchController.searchBar setBarTintColor:UIColor.yellowColor];
          [self.navigationItem.searchController.searchBar setTintColor:UIColor.greenColor];
     } else {
          self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
     }

我尝试过背景,巴结,色调,但问题仍然存在 enter image description here

0 个答案:

没有答案