I have a UITableView
to which I add programmatically a UISearchController
as a header. Since I'm adding it programmatically, I can't change the font from the storyboard. I need to change the UISearchBar
font to match the font of the rest of the app. I would need to either change the font of a UISearchBar
or of the whole tableViewHeader
I saw that there's a similar question with an answer in objective-c, however I'm developing my app in Swift and I tried to convert the answer on the other question to the following code but it still won't work :
let lightFont = UIFont(name: "GothamRounded-Light", size: 15)
for subview in searchController.searchBar.subviews {
if subview is UITextField{
(subview as! UITextField).font = lightFont
}
}