Hamish Rickerby

Menu

  • Home
  • Archives
  • Tags
  • About Hamish
  • RSS
May 19, 2012

"UISearchBar's UITextField"

For an update that I'm making to Moving Van (you should buy it now!) I need to customise the font that is displayed in a UISearchBar's text field. The search bar does not actually expose it's UITextField property, but because the search bar is a UIView, it's trivial to access the field to allow customisation.

for (UIView *searchSubview in mySearchBar.subviews) {
  if ([searchSubview isKindOfClass:[UITextField class]]) {
    // Do your text field customisation in here
    [(UITextField *)searchSubview setTextColor:[UIColor redColor]];
  }
}

HTH.


« "Core Data Migrations and Large Data Sets" "iBooks Crashing?" »

Copyright © 2023 Hamish Rickerby

Powered by Cryogen | Free Website Template by Download Website Templates