在iOS7中删除UISearchBar的边框 [英] Remove Border of UISearchBar in iOS7

查看:134
本文介绍了在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];

这篇关于在iOS7中删除UISearchBar的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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