Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar Minimal Style makes tint black when typing

When I set my UISearchBar to minimal style in iOS7, when I select it the tint becomes black, and the text is impossible to read because there's black on black.

This does not produce the desired result. The tint is still black when selected...

if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
{
    // set bar style
    _sendToSearchBar.barStyle = UIBarStyleDefault;
    // set bar transparancy
    _sendToSearchBar.translucent = NO;
    // set bar color
    _sendToSearchBar.barTintColor = [UIColor whiteColor];
    // set bar button color
    _sendToSearchBar.tintColor = [UIColor whiteColor];
    // set bar background color
    _sendToSearchBar.backgroundColor = [UIColor whiteColor];
}

enter image description here

like image 465
Apollo Avatar asked Apr 04 '14 06:04

Apollo


1 Answers

I had same problem and tried for few hours, the conclusion is UISearchBar are quite buggy ! Especially in "minimal" mode.

My workaround is :

  • Set the search style to Default (Prominent)
  • Set the BackgroundImage (Not BackgroundColor) to a transparent image or create an UIImage using [UIColor clearColor]
  • Set the BarTintColor to [UIColor blackColor]
  • Set the TintColor to [UIColor whiteColor]

The search bar looks like minimal mode in normal, and the background will be white when selected, so you can see the black color text.

The workaround isn't perfect, it just work, hope can help.

like image 198
Rex Lam Avatar answered Oct 23 '22 09:10

Rex Lam