searchBar 去黑线,改颜色

searchBar 去黑线,改颜色_第1张图片
15D33533-33D9-4735-AF2A-B2DF0978AB04.png

import UIKit

let Color_Search_Bar = UIColor.init(white: 240.0/255.0, alpha: 1.0) // f0f0f0

class UIVViewController2: UIViewController, UISearchBarDelegate {



@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var searchBar: UISearchBar!
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    
    self.searchBar.sizeToFit()
    self.searchBar.placeholder = "搜索"
    self.searchBar.tintColor = UIColor.black
    self.searchBar.delegate = self
    self.searchBar.barTintColor = Color_Search_Bar
    /* 去除黑线 */
    self.searchBar.backgroundImage = UIImage()
    self.searchBar.backgroundColor = Color_Search_Bar
    
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
    
    print("click search button")
}

}

你可能感兴趣的:(searchBar 去黑线,改颜色)