Friday, December 20, 2013

UISearchBar how to remove the white area

UISearchBar never been able to remove the white area, that is, clear the background color, or white areas can be changed to other colors, solving

UISearchBar * searchBar = [[UISearchBaralloc] initWithFrame: CGRectMake (15.0f, 30.0f, 145.0f, 45.0f)];
searchBar.placeholder = @ "Enter Name";
searchBar.delegate = self;
searchBar.showsCancelButton = NO;
searchBar.showsScopeBar = NO;
searchBar.barStyle = UIBarStyleBlackTranslucent;
searchBar.inputView.backgroundColor = [UIColorclearColor];
searchBar.alpha = 1.0f;
searchBar.backgroundColor = [UIColorclearColor];
for (UIView * subview in searchBar.subviews)
{
if ([subview isKindOfClass: NSClassFromString (@ "UISearchBarBackground")])
{
[Subview removeFromSuperview];
break;
}
}
[[[SearchBar subviews] lastObject] setBackgroundColor: [UIColorcolorWithRed: 0.118fgreen: 0.118fblue: 0.118falpha: 1.0f]];
searchBar.keyboardType = UIKeyboardTypeDefault;
[Self addSubview: searchBar];
self._searchBar = searchBar;
[SearchBar release];
Reply:
/ / Set the background color
UIImage * imageBgSearch = [UIImage imageNamed: @ "bg_searchBar.png"];
UITextField * a = [[searchBar subviews] objectAtIndex: 1];
a.textColor = [UIColor whiteColor];
a.background = imageBgSearch;
/ / (UITextField *) [[searchBar subviews] objectAtIndex: 1] background =. [UIImage imageNamed: @ "bg_searchBar.png"];

for (UIView * subview in searchBar.subviews)
{
if ([subview isKindOfClass: NSClassFromString (@ "UISearchBarBackground")])
{
[Subview removeFromSuperview];
break;
}
}
Reply:
What is white? ? Indissoluble
Reply:
Enter the keyword is when UITextField background is white Yeah, been resolved, thank you attention.

No comments:

Post a Comment