Rectangle 27 0

for(UIView *subView in searchBar.subviews) {
    if ([subView isKindOfClass:[UITextField class]]) {
        UITextField * textField = (UITextField *)subView;
        textField.font = [UIFont fontWithName:@"Helvetica" size:40];
    }
}

In case of the SWIFT you should use UISearchBar reference.

Thanks for the response, but my main issue is with converting the Objective-C code into Swift. For example, in the first line, I can't use searchBar.subviews.

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

for subView in searchBar.subviews  {
  for subsubView in subView.subviews  {
      if let textField = subsubView as? UITextField {
        textField.attributedPlaceholder =  NSAttributedString(string:NSLocalizedString("Search", comment:""),
          attributes:[NSForegroundColorAttributeName: UIColor.orangeColor()])
      }
  }
}

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

for subView in searchBar.subviews  {
  for subsubView in subView.subviews  {
      if let textField = subsubView as? UITextField {
        textField.attributedPlaceholder =  NSAttributedString(string:NSLocalizedString("Search", comment:""),
          attributes:[NSForegroundColorAttributeName: UIColor.orangeColor()])
      }
  }
}

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

This is the easiest practise for changing the Font or any other similar changes in the textfield of searchBar. I have been using XCode 8.4, Swift 3.x, iOS 10.x.

extension UISearchBar {

func change(textFont : UIFont?) {

    for view : UIView in (self.subviews[0]).subviews {

        if let textField = view as? UITextField {
            textField.font = textFont
        }
    }
} }

The above code can be called directly where you make an IBOutlet of the searchBar...

@IBOutlet weak var searchBar: UISearchBar! {
    didSet {
        searchBar.change(textFont: GlobalConstants.Font.avenirBook14)
    }
}

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

let textFieldInsideUISearchBar = searchBar.value(forKey: "searchField") as? UITextField
    let placeholderLabel       = textFieldInsideUISearchBar?.value(forKey: "placeholderLabel") as? UILabel
    placeholderLabel?.font     = UIFont.systemFont(ofSize: 12.0)

Just in case anyone else is struggling to make this work, if you're using storyboards, you need to set a placeholder value on the storyboard's search bar before using this code

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

//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()

"placeholderLabel" does not seem to work anymore (iOS10), but changing the font of the "searchField" changes both, the placeholder font and the text font as well

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont
Rectangle 27 0

if #available(iOS 9.0, *) {
    UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).font = UI.getInstance.tinyFont
} else {
    func checkSubview(view:UIView)
    for subView in view.subviews {
        if subView is UITextField {
            let textField = subView as! UITextField
            textField.font = UI.getInstance.tinyFont
        } else {
            checkSubview(subView)
        }

    }
    checkSubview(view)
}

ios - Changing Search Bar placeholder text font in Swift - Stack Overf...

ios xcode swift uisearchbar uifont