iphone:searchbar remove background when interface changes
I have used this code to remove background behind searchbar but when I rotate the view to Landscape or launch the application in landscape view a black contai开发者_如何学Goner is displayed around searchbar
for (UIView *searchSubview in mySearchBar.subviews) {
NSLog(@"Subview: %@", searchSubview);
if ([searchSubview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
//[searchSubview removeFromSuperview];
[searchSubview setAlpha:0.0];
//[searchSubview setBackgroundColor:[UIColor clearColor]];
//break;
}
}
Please enlighten me on this. I tried to implement this code in willRotate, shouldRotate and didRotate methods but problem persist. Please enlighten me on this.
Regards Ankit
got it ....
open the interface builder under searchbar attributes in view, Mode is set as 'Redraw' set it to scaleToFill
精彩评论