替换UISearchBar的取消按钮
2016-04-18 14:40
633 查看
MySearch = [[UISearchBaralloc]initWithFrame:CGRectMake(0,0,KWIDTH,60)]; MySearch.delegate=self; MySearch.showsCancelButton=YES; // [MySearch setTintColor:[UIColor redColor]]; //设置闪烁输入的头的颜色 // [MySearch setBarTintColor:[UIColor greenColor]]; //设置输入框的Bar的背景颜色 MySearch.placeholder=@"请输入客户名称、条码搜索..."; //遍历搜索条的上面的所有子视图,取下标为0的(Cancel按钮)取出Cancel上的所有子视图 for(UIView *viewin [[[MySearchsubviews]objectAtIndex:0]subviews]) { //找到继承UINavigationButton类的View,继承过来 if([viewisKindOfClass:[NSClassFromString(@"UINavigationButton")class]]) { //创建一个按钮,继承上面的继承的View UIButton * cancel =(UIButton *)view; cancel.bounds=CGRectMake(0,0,30,30); // [cancel setImage:[UIImage imageNamed:@"01.png"] forState:UIControlStateNormal]; //[cancel setBackgroundImage:[UIImage imageNamed:@"01.png"] forState:UIControlStateNormal]; //[cancel setTitle:@"取消" forState:UIControlStateNormal]; [cancel setTintColor:[UIColorblackColor]]; [cancel.titleLabelsetTextColor:[UIColorblackColor]]; } } [self.viewaddSubview:MySearch];
相关文章推荐
- iOS开发之指定UIView的某几个角为圆角
- String、StringBuffer、StringBuilder的区别
- Swifit指纹识别小Demo
- IOS Quartz2D 通过UIColor生成图片
- UITableView优化技巧
- 解决通过UIAlertView按钮点击事件pop回上级页面键盘会响应问题
- EasyUI tree 相关
- Sketch真的很难上手?
- [Android实例] Handler+ExecutorService(线程池)+MessageQueue模式+缓存模式
- iOS - UISearchController搜索框与NSPredicate谓词
- identityHashCode, WeakReference,ReferenceQueue和Lucene WeakIdentityMap
- UITableView的常用代理方法
- AVI Player with Playmaker actions 使用UGUI显示视频以及控制播放视频 (二)
- 理解 Android Build 系统
- AndroidUI--SlidingMenu使用例子
- IOS-UITableView入门(2)
- 背水一战 Windows 10 (7) - 控件 UI: VisualState, VisualStateManager, 控件的默认 UI
- 原生的强大DOM选择器querySelector
- String、StringBuffer和StringBuilder的区别
- 南京理工大学第八届程序设计大赛(校外镜像) F sequence