iPad / iPhone uiSearchbar透明背景 [英] iPad/iPhone uiSearchbar transparent background
问题描述
我知道这些问题之前已被问及(并已解决),但这对我不起作用。
事实上,我已经解决了,但这个问题突然冒出来让我头疼。
I know this questions was asked(and solved) before, but this wont work for me. as a matter of fact, I had it already solved, but this issue came back out of nowhere and struck me on the head.
我不能设置我的 UISearchBar
透明的背景。
我一直在使用:
I am not able to set the background of my UISearchBar
transparent.
I was always using:
searchBar.backgroundColor = [UIColor clearColor];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
它工作得很好......但突然停了下来。可能是因为我升级了我的xcode版本,但我不确定。
我花了几个小时调查过这个..
有人在那里做这个吗?请指出我正确的方向。
谢谢堆!!!
and it worked nicely... but suddenly it stopped. could be since I upgraded my xcode-version but I am not sure. I spent a couple of hours already investigating this.. Is somebody out there to do this? please point me in the right direction. thanks heaps!!!
最好的问候
T
best regards T
推荐答案
尝试循环浏览子视图并寻找合适的类:
Try looping through your subviews and look for the right class:
for (UIView *subview in searchBar.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[subview removeFromSuperview];
break;
}
}
我不确定,但我认为你不能假设索引0是背景视图。
以上示例适用于我。
I'm not sure but I dont think you can assume that index 0 is the background view. The example above works for me.
这篇关于iPad / iPhone uiSearchbar透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!