IOS6和IOS7 显示一样的SearchBar

 if (isIOS7) {
mySearchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(, , , )];
mySearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
mySearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
mySearchBar.keyboardType = UIKeyboardTypeDefault;
mySearchBar.placeholder = @"全国地区(中文/拼音/区号/别名) ";
mySearchBar.delegate =self;
mySearchBar.tag = ;
mySearchBar.showsCancelButton =NO;//是否显示取消按钮
[mySearchBar setBackgroundColor:MF_ColorFromRGB(, , )];
[[[[mySearchBar.subviews objectAtIndex:] subviews] objectAtIndex:] removeFromSuperview]; // 去掉搜索框背景
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:MF_ColorFromRGB(, , )]; // 修改placeholder textColor
[self.view addSubview:mySearchBar];
}
else
{
mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(, , , )];
mySearchBar.delegate = self;
mySearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
mySearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
mySearchBar.placeholder = @"全国地区(中文/拼音/区号/别名)";
mySearchBar.keyboardType = UIKeyboardTypeDefault;
[mySearchBar setTranslucent:YES];
mySearchBar.backgroundColor = MF_ColorFromRGB(, , );
[[mySearchBar.subviews objectAtIndex:]removeFromSuperview]; // 去掉搜索框背景
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:MF_ColorFromRGB(, , )]; // 修改placeholder textColor
[self.view addSubview:mySearchBar]; // 替换UITextField背景图
UITextField* searchField = nil;
for (UIView* subview in mySearchBar.subviews) {
if ([subview isKindOfClass:[UITextField class]])
{
searchField = (UITextField*)subview;
break;
}
}
searchField.background = [MF_PngWithSkin(DEFAULTS_SKIN, @"search_Bar_bgImg.png") stretchableImageWithLeftCapWidth: topCapHeight:];
}
上一篇:TPYBoard V102:能跑Python的stm32开发板


下一篇:Hadoop源码学习笔记(3) ——初览DataNode及学习线程