Eri*_*ong 2 iphone uisearchbar ios4
我正在尝试删除UISearchBar的背景以使其透明.我试过这些解决方案:
1.
for (UIView *subview in searchBar.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[subview removeFromSuperview];
break;
}
}
Run Code Online (Sandbox Code Playgroud)
2.
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)
这两种方法都适用于iOS 4.3,但不适用于4.1.它显示黑色.如何在iOS 4.1上运行?我正在使用SDK 4.3.谢谢.
这应该工作:
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
[searchBar setBackgroundColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)