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];
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