修改UISearchBar背景色

//iOS7.1
[[[[_searchBar.subviews objectAtIndex:0] subviews] objectAtIndex:0] removeFromSuperview];
[_searchBar setBackgroundColor:[UIColor colorWithRed:245.f/255.f green:238.f/255.f blue:219.f/255.f alpha:1]];

//iOS7.0
[_searchBar setBarTintColor:[UIColor clearColor]];
[_searchBar setBackgroundColor:[UIColor colorWithRed:245.f/255.f green:238.f/255.f blue:219.f/255.f alpha:1]];

//iOS7.0以下
[[_searchBar.subviews objectAtIndex:0] removeFromSuperview];
[_searchBar setBackgroundColor:[UIColor colorWithRed:245.f/255.f green:238.f/255.f blue:219.f/255.f alpha:1]];

 

posted @ 2014-06-12 08:56  菜鸟程序猿  阅读(261)  评论(0编辑  收藏  举报