I\'m testing out my UI and I find the search bar a little bit too narrow for my liking. I also want to make sure people with poorer vision or poorer manual dexterity have n
This is the correct Swift 4.0 answer on how to change the height of a UISearchBar:
let image = getImageWithColor(color: UIColor.clear, size: CGSize(width: 1, height: 40))
searchBar.setSearchFieldBackgroundImage(image, for: .normal)
Using following method:
func getImageWithColor(color: UIColor, size: CGSize) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(rect)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
Tested on 4th. June. 2018