在iOS7中删除UISearchBar的边框
问题描述:
我正在尝试在iOS 7中删除UISearchBar的边框。在iOS 6中,它工作正常。我以编程方式创建了UISearchBar。我几乎尝试了Stack Overflow和Google的所有东西。
I'm trying to remove border of UISearchBar in iOS 7. In iOS 6 it's working fine. I created the UISearchBar programatically. I tried almost every thing from Stack Overflow and Google.
立即查看SearchBar
SearchBar looking right now
我想要实现的目标
What i want to achieve
我尝试了下面提到的所有这些东西
I tried all these stuffs mentioned below
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor whiteColor] CGColor];
和
for (id img in searchBar.subviews)
{
if ([img isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
[img removeFromSuperview];
}
}
和
for (UIView *sub in self.tableView.tableHeaderView.subviews) {
if ([sub isKindOfClass:[UIImageView class]]) {
sub.hidden = YES;
}
}
但仍未成功。
答
我找到了解决办法:设置
UISearchBar的
barTintColor
code>到 clearColor
I found the solution: set the barTintColor
of UISearchBar
to clearColor
topSearchBar.barTintColor = [UIColor clearColor];