I am trying to change the font of the placeholder text in the search bar within my Search Display Controller. I was looking at some examples and I tried to implement them but as they are in Objective-C, I wasn't able to find any that I could get to work.
For example, I tried this one:
UITextField *textField = [[searchBar subviews] objectAtIndex:1]; [textField setFont:[UIFont fontWithName:@"Helvetica" size:40]];
But I was unable to get past var textField: UITextField = UISearchBar
Any ideas?
SwiftUI lets you customize Text by applying a . font() modifier. The default iOS font is called San Francisco and if you don't explicitly change it, then all of your text will have the default iOS look. Some other options of standard fonts include: title, headline, subheadline, body, callout, caption or footnote.
Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
//SearchBar Text let textFieldInsideUISearchBar = dashBoardSearchBar.valueForKey("searchField") as? UITextField textFieldInsideUISearchBar?.textColor = UIColor.whiteColor() //SearchBar Placeholder let textFieldInsideUISearchBarLabel = textFieldInsideUISearchBar!.valueForKey("placeholderLabel") as? UILabel textFieldInsideUISearchBarLabel?.textColor = UIColor.whiteColor()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With