不知道从哪个帖子上看到的
- (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]];
}
}