Skip to content

Instantly share code, notes, and snippets.

@johnclayton
Created March 28, 2012 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnclayton/2228502 to your computer and use it in GitHub Desktop.
Save johnclayton/2228502 to your computer and use it in GitHub Desktop.
- (UITextField *) textField {
UITextField *textField = nil;
for (id subview in [self subviews]) {
if ([subview isKindOfClass:[UITextField class]]) {
textField = (UITextField *)subview;
break;
}
}
return textField;
}
- (UIView *) backgroundView {
UIView *backgroundView = nil;
for (id subview in [self subviews]) {
NSString *subviewClassName = NSStringFromClass([subview class]);
if ([subviewClassName isEqualToString:@"UISearchBarBackground"]) {
backgroundView = (UIView *)subview;
break;
}
}
return backgroundView;
}
- (UIButton *) cancelButton {
UIButton *cancelButton = nil;
for (id subview in [self subviews]) {
NSString *subviewClassName = NSStringFromClass([subview class]);
if ([subviewClassName isEqualToString:@"UINavigationButton"]) {
if([[(NSObject *)subview performSelector:@selector(title)] isEqualToString:@"Cancel"]) {
cancelButton = (UIButton *)subview;
break;
}
}
}
return cancelButton;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment