Skip to content

Instantly share code, notes, and snippets.

@MosheBerman
Created August 5, 2014 16:31
Show Gist options
  • Select an option

  • Save MosheBerman/33c2f50049e10085b007 to your computer and use it in GitHub Desktop.

Select an option

Save MosheBerman/33c2f50049e10085b007 to your computer and use it in GitHub Desktop.
What I tried before using a solid image.
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self colorAllTheViews:self.searchDisplayController.searchBar.superview];
}
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
{
[self fungeBackdrop];
}
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
{
NSLog(@"Search will end.");
}
- (void)fungeBackdrop
{
UIView *backdrop = [self backdropViewInSearchBar:self.searchDisplayController.searchBar.superview];
backdrop.opaque = YES;
backdrop.backgroundColor = [BRKThemeManager sharedManager].maroonColor;
}
/**
*
*/
- (void)colorAllTheViews:(UIView *)view
{
for (UIView *subview in view.subviews)
{
//
if (subview.alpha == 0.85)
{
subview.alpha = 1.0;
subview.backgroundColor = [BRKThemeManager sharedManager].maroonColor;
[self colorAllTheViews:subview];
}
}
}
/**
* Attempt to extract private view. Whelp!
*/
- (UIView *)backdropViewInSearchBar:(UIView *)view
{
UIView *backdrop = nil;
for (UIView *subview in view.subviews)
{
backdrop = [self backdropViewInSearchBar:subview];
if(!backdrop)
{
NSString *className = [NSStringFromClass([subview class]) lowercaseString];
BOOL isBackdrop = [className rangeOfString:@"back"].location != NSNotFound;
if (isBackdrop) {
backdrop = subview;
break;
}
}
}
return backdrop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment