Remove top and bottom shadow when UISearchBar is added in UITableView.

This commit is contained in:
SBiOSoftWhare 2020-07-06 20:40:47 +02:00
parent 1a1c223540
commit 5347b1f0e7
2 changed files with 14 additions and 12 deletions

View file

@ -94,20 +94,21 @@ class DarkTheme: NSObject, Theme {
// The navigation bar needs to be opaque so that its background color is the expected one
navigationBar.isTranslucent = false
}
func applyStyle(onSearchBar searchBar: UISearchBar) {
searchBar.barStyle = .default
searchBar.searchBarStyle = .default
searchBar.barStyle = .black
searchBar.barTintColor = self.baseColor
searchBar.isTranslucent = false
searchBar.backgroundImage = UIImage() // Remove top and bottom shadow
searchBar.tintColor = self.tintColor
if #available(iOS 13.0, *) {
searchBar.searchTextField.backgroundColor = self.searchBackgroundColor
searchBar.searchTextField.textColor = self.searchPlaceholderColor
searchBar.tintColor = self.tintColor
} else {
searchBar.tintColor = self.searchPlaceholderColor
if let searchBarTextField = searchBar.vc_searchTextField {
searchBarTextField.textColor = searchBar.tintColor
searchBarTextField.textColor = self.searchPlaceholderColor
}
}
}

View file

@ -102,20 +102,21 @@ class DefaultTheme: NSObject, Theme {
// The navigation bar needs to be opaque so that its background color is the expected one
navigationBar.isTranslucent = false
}
func applyStyle(onSearchBar searchBar: UISearchBar) {
searchBar.barStyle = .default
searchBar.searchBarStyle = .default
searchBar.barStyle = .black
searchBar.barTintColor = self.baseColor
searchBar.isTranslucent = false
searchBar.backgroundImage = UIImage() // Remove top and bottom shadow
searchBar.tintColor = self.tintColor
if #available(iOS 13.0, *) {
searchBar.searchTextField.backgroundColor = self.searchBackgroundColor
searchBar.searchTextField.textColor = self.searchPlaceholderColor
searchBar.tintColor = self.tintColor
} else {
searchBar.tintColor = self.searchPlaceholderColor
if let searchBarTextField = searchBar.vc_searchTextField {
searchBarTextField.textColor = searchBar.tintColor
searchBarTextField.textColor = self.searchPlaceholderColor
}
}
}