Thursday, June 7, 2012

How To Remove Background Of UISearchBar in iphone

To remove background of UISearchBar first set search bar background color clear color putting following  one line code
searchBar.backgroundColor = [UIColor clearColor];

After adding Subview of UISearchBar [self.view addSubview:searchBar];
Then use any one Method following code

Method:1
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
                            OR
Method:2
for (UIView *subview in searchBar.subviews) {

        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {

            [subview removeFromSuperview];

            break;
        }
    }

No comments:

Post a Comment