iOS UISearchBar改变搜索框的颜色
2016-11-14 14:19
323 查看
[objc] view
plain copy
//搜索框
- (UISearchBar *)searchBar{
if (_searchBar == nil) {
_searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 27, KScreenWidth, 30)];
_searchBar.placeholder = @"请输入搜索内容";
_searchBar.backgroundImage = [[UIImage alloc] init];
_searchBar.delegate = self;
_searchBar.tintColor = LHColor(196, 196, 196);
//取出textfield
UITextField *searchField=[_searchBar valueForKey:@"_searchField"];
// searchField.backgroundColor = [UIColor grayColor];
// searchField.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:@"ic_map_topbar_search"]];
// searchField.background = [UIImage imageNamed:@"ic_map_topbar_search"];
//改变searcher的textcolor
searchField.borderStyle = UITextBorderStyleNone;
// searchField.background = [UIImage imageNamed:@"ic_top"];
searchField.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.3];
searchField.layer.cornerRadius = 4.0;
searchField.leftViewMode=UITextFieldViewModeNever;
searchField.textColor=[UIColor whiteColor];
//改变placeholder的颜色
[searchField setValue:[UIColor whiteColor]forKeyPath:@"_placeholderLabel.textColor"];
}
return _searchBar;
}
plain copy
//搜索框
- (UISearchBar *)searchBar{
if (_searchBar == nil) {
_searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 27, KScreenWidth, 30)];
_searchBar.placeholder = @"请输入搜索内容";
_searchBar.backgroundImage = [[UIImage alloc] init];
_searchBar.delegate = self;
_searchBar.tintColor = LHColor(196, 196, 196);
//取出textfield
UITextField *searchField=[_searchBar valueForKey:@"_searchField"];
// searchField.backgroundColor = [UIColor grayColor];
// searchField.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:@"ic_map_topbar_search"]];
// searchField.background = [UIImage imageNamed:@"ic_map_topbar_search"];
//改变searcher的textcolor
searchField.borderStyle = UITextBorderStyleNone;
// searchField.background = [UIImage imageNamed:@"ic_top"];
searchField.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.3];
searchField.layer.cornerRadius = 4.0;
searchField.leftViewMode=UITextFieldViewModeNever;
searchField.textColor=[UIColor whiteColor];
//改变placeholder的颜色
[searchField setValue:[UIColor whiteColor]forKeyPath:@"_placeholderLabel.textColor"];
}
return _searchBar;
}
相关文章推荐
- iOS UISearchBar改变搜索框的颜色
- IOS改变UISearchBar中搜索框的高度
- iOS UISearchBar调整搜索框的颜色
- iOS UISearchController中 如何改变UISearchBar中取消按钮的颜色和字
- UISearchBar改变搜索框的高度
- iOS开发问题——UISearchBar背景颜色去除问题
- iOS中UISearchBar(搜索框)使用总结
- iOS中UISearchBar(搜索框)使用总结
- UISearchBar 的字体背景颜色属性图片替换,打造自己想要的搜索框
- iOS之搜索框UISearchController的使用(iOS8.0以后替代UISearchBar+display)
- iOS - 搜索框UISearchController的使用(iOS8.0之后替代UISearchBar + UISearchDisplayController的组合)
- UISearchBar改变输入框的背景颜色
- UISearchBar 改变编辑去背景颜色
- IOS 改变UISearchBar的背景色
- iOS中UISearchBar(搜索框)使用总结
- UISearchBar--改变内部输入框的背景颜色
- iOS搜索框UISearchBar
- iOS中UISearchBar(搜索框)使用总结
- UIsearchBar背景颜色的改变,占位字符的颜色改变,占位字符字体大小改变
- iOS UISearchBar的背景框颜色适应