开发者

iphone:searchbar remove background when interface changes

开发者 https://www.devze.com 2023-02-28 02:17 出处:网络
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 sea

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号