UISearchBar删除iOS 4.1上的背景 [英] UISearchBar remove background on iOS 4.1

查看:90
本文介绍了UISearchBar删除iOS 4.1上的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除UISearchBar的背景以使其透明。我尝试了这些解决方案:

I'm trying to remove the background of UISearchBar to make it transparent. I tried these solutions:

1。

for (UIView *subview in searchBar.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
    [subview removeFromSuperview];
    break;
}
}

2.

[[searchBar.subviews objectAtIndex:0] removeFromSuperview];

这两种方法既适用于iOS 4.3,也适用于4.1。它显示黑色。如何在iOS 4.1上运行?我正在使用SDK 4.3。谢谢。

These two methods both work on iOS 4.3, but not on 4.1. it shows black. How can I make it work on iOS 4.1? I'm using SDK 4.3. Thanks.

推荐答案

这应该有效:

[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
[searchBar setBackgroundColor:[UIColor clearColor]];

这篇关于UISearchBar删除iOS 4.1上的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆