试试这个:
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor blueColor] CGColor];
针对Swift 3:
searchBar.layer.borderWidth = 1
searchBar.layer.borderColor = searchBar.barTintColor?.cgColor
self.searchBar.backgroundImage = UIImage()
UISearchBar
突出。同时,我们也被赋予了根据自己需求进行调整的方法 :)。 - Abhinav