Skip to content

Instantly share code, notes, and snippets.

@hebertialmeida
Created November 19, 2013 17:09
Show Gist options
  • 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