Skip to content

Instantly share code, notes, and snippets.

@hebertialmeida
Created November 19, 2013 17:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hebertialmeida/7548793 to your computer and use it in GitHub Desktop.
Save hebertialmeida/7548793 to your computer and use it in GitHub Desktop.
Set Keyboard Appearance of UISearchBar, iOS 5 to iOS 7
- (void)customKeyboardOnSearchBar:(UISearchBar *)searchBar
{
for(UIView *subView in searchBar.subviews) {
if([subView conformsToProtocol:@protocol(UITextInputTraits)]) {
[(UITextField *)subView setKeyboardAppearance:UIKeyboardAppearanceAlert];
[(UITextField *)subView setReturnKeyType:UIReturnKeyDone];
} else {
for(UIView *subSubView in [subView subviews]) {
if([subSubView conformsToProtocol:@protocol(UITextInputTraits)]) {
[(UITextField *)subSubView setReturnKeyType:UIReturnKeyDone];
[(UITextField *)subSubView setKeyboardAppearance:UIKeyboardAppearanceAlert];
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment