Skip to content

Instantly share code, notes, and snippets.

@marinat
Last active September 17, 2018 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinat/101c073258004d6ea524ae0c7bf0dd56 to your computer and use it in GitHub Desktop.
Save marinat/101c073258004d6ea524ae0c7bf0dd56 to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// TestSearchView
//
// Created by Gusli Android Dev on 17.09.2018.
// Copyright © 2018 Gusli Dev. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let searchController = UISearchController(searchResultsController: nil)
searchController.searchBar.isTranslucent = false
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white]
if let textfield = searchController.searchBar.value(forKey: "searchField") as? UITextField {
//let ss = sw?.subviews
if let backgroundview = textfield.subviews.first {
// Background color
//backgroundview.backgroundColor = hexStringToUIColor(hex: "#8392B0")
backgroundview.backgroundColor = UIColor.themeColor
}
}
navigationItem.searchController = searchController
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension UIColor
{
class var themeColor:UIColor {
return UIColor(red: 131.0/255.0, green: 146.0/255.0, blue: 176.0/255.0, alpha: 1.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment