透明UISearchBar

```

customSearchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(40, 27, kSCREEN_WIDTH-60, 30)];

customSearchBar.backgroundColor = [UIColor clearColor];

[customSearchBar setBackgroundImage:[UIImage new]];

[customSearchBar setTranslucent:YES];

customSearchBar.placeholder = @"Search";

[self.view addSubview:customSearchBar];

customSearchBar.returnKeyType=UIReturnKeySearch;

[customSearchBar setTintColor:[UIColor whiteColor]];

customSearchBar.delegate = self;

//去掉searchbar背景

customSearchBar.searchBarStyle = UISearchBarStyleProminent;

//改变输入框内字体的颜色

UITextField *searchField = [customSearchBar valueForKey:@"_searchField"];

// Change search bar text color

searchField.textColor = [UIColor whiteColor];

searchField.layer.borderWidth = 0.6;

searchField.layer.borderColor = [UIColor whiteColor].CGColor;

searchField.layer.masksToBounds = YES;

searchField.layer.cornerRadius = 5;

searchField.backgroundColor=[UIColor clearColor];

```

你可能感兴趣的:(透明UISearchBar)