您的位置:首页 > 其它

删除searchBar 背景

2015-06-03 14:33 190 查看
不知道从哪个帖子上看到的 

- (void)removeSearchBarFrame:(UISearchBar *)searchBar
{

    float version = [[[UIDevice
currentDevice] systemVersion]
floatValue];

    
   
if ([searchBar respondsToSelector :
@selector (barTintColor)]) {
       
float  iosversion7_1 = 7.1 ;
       
if (version >= iosversion7_1)
        {
           
//iOS7.1

            

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

            [searchBar setBackgroundColor:[UIColor
clearColor]];
        }
       
else
        {
           
//iOS7.0

            [searchBar setBarTintColor:[UIColor
clearColor]];

            [searchBar setBackgroundColor:[UIColor
clearColor]];
        }
    }
   
else
    {

        //iOS7.0
以下

        

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

        [searchBar setBackgroundColor :[
UIColor clearColor]];
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: