How to change SearchBar border color

search bar color
search bar background color swift
custom search bar swift
ios 13 search bar text color
uisearchbar textfield background color swift 4
uisearchbar icon color
uisearchcontroller tint color
uisearchbar search icon position swift

I would like to change grey border color in my Search Bar to white color. Now it looks like that:

I achieved this effect after using this lines of code, but "inside border" is still grey:

var searchBar: UISearchController!

    self.searchBar.searchBar.backgroundColor = UIColor.whiteColor()
    self.searchBar.searchBar.layer.borderWidth = 3
    self.searchBar.searchBar.layer.borderColor = UIColor.whiteColor().CGColor
    self.searchBar.searchBar.layer.backgroundColor = UIColor.whiteColor().CGColor
    self.searchBar.searchBar.tintColor = UIColor(red: 0.3, green: 0.63, blue: 0.22, alpha: 1)

Can somebody help me in it?

self.searchBar.searchBar.searchBarStyle = UISearchBarStyle.Prominent
self.searchBar.searchBar.translucent = false
let textFieldInsideSearchBar = self.searchBar.searchBar.valueForKey("searchField") as? UITextField
textFieldInsideSearchBar?.backgroundColor = UIColor.whiteColor()
self.searchBar.searchBar.barTintColor = UIColor.whiteColor()

Code above will give you all white searchbar but likely there will be black lines at top and bottom of the searchbar as you can see from the attachment. If you see the black lines and if you don't want them, change;

self.searchBar.searchBar.barTintColor = UIColor.whiteColor()


self.searchBar.searchBar.backgroundImage = UIImage(named: "nameOfYourWhiteImage")

And you will have a clean white searchbar. Hope this solves your problem. Good luck!

Remove top and bottom border of UISearchBar and shadow , Set the bar's backgroundImage to an empty UIImage , not nil : searchBar. borderWidth = 10 searchBar.layer.borderColor = UIColor.white.cgColor var textField : UITextField for subview in searchBar.subviews { if (subview. To apply your accent color to your window borders, scroll down to the “Show accent color on the following surfaces” section, and then enable the “Title bars and window borders” option. You’ll see colored tabs in your title bars instead of fully colored title bars thanks to the Sets feature.

You can try self.searchBar.searchBar.searchBarStyle = UISearchBarStyle.minimal to get a clean look with white background, no lines at top or bottom and slightly grey inside to see the actual search field.

How to change border and icons in Search bar (Swift), To add borders use the views layer property. self.searchBar.layer.borderColor = UIColor.blueColor().CGColor self.searchBar.layer.borderWidth  If the border-color property has two values: border-color: red green; top and bottom borders are red; right and left borders are green; If the border-color property has one value: border-color: red; all four borders are red; Note: Always declare the border-style property before the border-color property. An element must have borders before you

I suggest using 2 handy extensions for that:

extension UIImage {
    static func imageFromLayer (layer: CALayer) -> UIImage? {
        guard let currentContext = UIGraphicsGetCurrentContext() else {return nil}
        layer.render(in: currentContext)
        let outputImage = UIGraphicsGetImageFromCurrentImageContext()
        return outputImage

extension UISearchBar {
    func setCustomBackgroundColor (color: UIColor) {
        let backgroundLayer = CALayer()
        backgroundLayer.frame = frame
        backgroundLayer.backgroundColor = color.cgColor
        if let image = UIImage.imageFromLayer(layer: backgroundLayer) {
            self.setBackgroundImage(image, for: .any, barMetrics: .default)

Then just use:

self.searchBar.setCustomBackgroundColor (color: UIColor.white)

How to change outline/border color for the Search Bar? : FirefoxCSS, for the main URL bar, can I change the "#urlbar" part to reference these other bars? (Or is there another way of doing it?) #urlbar[focused=true] { border-color:  1. Open Search bar. Right-click the bottom left corner of the Start screen (or Desktop) to access the Quick Access Menu and choose Search on it to open the Search bar. 2. On the Search bar, choose Settings and input window border in the blank box. Then, click Change the color of your taskbar and window borders in the left results.

Customize Color, background from UISearchBar in Swift · GitHub, let searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: func changeSearchBarColor(fieldColor: UIColor, backColor: UIColor, borderColor: UIColor?) I'm working on an iOS custom renderer to change the background color of the text field within the search bar control in my Xamarin.Forms project but can't figure it out. This site uses cookies for analytics, personalized content and ads.

iOS Notes 30: How to customize UISearchBar? [Updated v2], How to change textColor? // TextField Color Customization let textFieldInsideSearchBar = searchBar.value(forKey: “searchField”) as? I want to change Searchbar Icon Image Or Color. This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use.

searchBarStyle, A search bar style that specifies the search bar's appearance. Style { get set } Style.minimal provides no default background color or image but will display  I'm still painfully aware of the focus border color being this bright blue color and I can't seem to figure out where to change it. I've looked into VisualStateManager's in order to set the border color when 'Focused' but as of yet I've not been able to actually apply it due to the compilation SearchBar seems to have with FormsTextBox

  • How do I remove the top and botton line in search bar