UIView* v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kSCREEN_WIDTH - 110, 30)];
//searchBar
UISearchBar* searchBar = [[UISearchBar alloc]initWithFrame:v.bounds];
searchBar.text = @"";
searchBar.translucent = YES;
searchBar.barStyle = UIBarStyleBlack;
//设置下样式
searchBar.searchBarStyle = UISearchBarStyleProminent;
//半透明背景图 自制一张半透明的Image
searchBar.backgroundImage = [UIImage imageWithColor:[UIColor clearColor] Size:v.bounds.size];
//设置SearchBar的textfield的背景图
[searchBar setSearchFieldBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0.3] Size:CGSizeMake(v.width, 30)] forState:UIControlStateNormal];
//
searchBar.layer.cornerRadius = 15;
searchBar.layer.masksToBounds = YES;
//设置searchBar的textfield的字体
[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]].textColor = [UIColor whiteColor];
//设置searchBar的textfield的清除按钮
[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]].clearButtonMode = UITextFieldViewModeNever;
searchBar.delegate = self;
// searchBar tex
[v addSubview:searchBar];