Osc*_*car 39 iphone uisearchbar
我想自定义搜索栏,我的意思是白盒子.我可以做吗?有关于此的一些文件吗?有没有办法隐藏白框,但不是字母.我可以至少让盒子变小吗?我的意思是减少身高
Ilk*_*aci 57
通过IOS 5.0你有机会使用
[[UISearchBar appearance] setSearchFieldBackgroundImage:[UIImage imageNamed:@"searchbar.png"]forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
Osc*_*car 27
这是我正在寻找的解决方案:子类化UISearchBar,并覆盖方法layoutSubviews
- (void)layoutSubviews {
UITextField *searchField;
NSUInteger numViews = [self.subviews count];
for(int i = 0; i < numViews; i++) {
if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) { //conform?
searchField = [self.subviews objectAtIndex:i];
}
}
if(!(searchField == nil)) {
searchField.textColor = [UIColor whiteColor];
[searchField setBackground: [UIImage imageNamed:@"buscador.png"] ];
[searchField setBorderStyle:UITextBorderStyleNone];
}
[super layoutSubviews];
}
Run Code Online (Sandbox Code Playgroud)
Kir*_*ela 16
// Search Bar Customization
// Background Image
[self.searchDisplayController.searchBar setBackgroundImage:[[UIImage alloc]init]];
// Backgroud Color
[self.searchDisplayController.searchBar setBackgroundColor:[UIColor redColor]];
// Search Bar Cancel Button Color
[[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor whiteColor]];
// set Search Bar Search icon
[self.searchDisplayController.searchBar setImage:[UIImage imageNamed:@"search_ico.png"]
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
// set Search Bar textfield background image
[[UISearchBar appearance] setSearchFieldBackgroundImage:[UIImage imageNamed:@"search_box.png"]
forState:UIControlStateNormal];
// set Search Bar texfield corder radius
UITextField *txfSearchField = [self.searchDisplayController.searchBar valueForKey:@"_searchField"];
txfSearchField.layer.cornerRadius = 10.8f;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
53635 次 |
| 最近记录: |