Last active
September 17, 2018 09:35
-
-
Save marinat/101c073258004d6ea524ae0c7bf0dd56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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