UISearchDisplayController “No Results“ cancel修改
1. Changing the title of the “cancel” button
If you want to localize your UISearchBar or just want to apply a unique text matching your application just implement the following UISearchDisplayControllerDelegate method:
-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller{
[searchBar setShowsCancelButton:YES animated:NO];
for(UIView *subView in searchBar.subviews){
if([subView isKindOfClass:[UIButton class]]){
[(UIButton*)subView setTitle:@"myCustomTitle" forState:UIControlStateNormal];
}
}
}
2. Changing the title of the “no results” label
Again you need to implement a delegate method
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString{
for(UIView *subview in searchController.searchResultsTableView.subviews) {
if([subview isKindOfClass:[UILabel class]]) {
[(UILabel*)subview setText:@"my custom 'no results' text"];
}
}
return YES;
}
3. Custom background image
Insert this snippet directly after you initialized your UISearchBar
searchBarOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SearchBarBack"]];
searchBarOverlay.frame = CGRectMake(-8, -2, 320, 48);
[searchBar addSubview:searchBarOverlay];
[searchBar sendSubviewToBack:searchBarOverlay]; for (UIView *v in [searchBar subviews]) { if ([NSStringFromClass([v class]) isEqualToString:@"UISearchBarBackground"])
{
[searchBar sendSubviewToBack:v];
} if ([NSStringFromClass([v class]) isEqualToString:@"UIImageView"] && v != searchBarOverlay)
{
[searchBar sendSubviewToBack:v];
}
}
5.Custom background color
Finally a one-liner
searchBar.tintColor = [UIColor redColor];
UISearchDisplayController “No Results“ cancel修改的更多相关文章
- yii 自动生成的内容,分页信息(Displaying 1-10 of 15 results.)如何修改或是yii cgridview template summary
问的白一点就是 Displaying 1-10 of 15 results 如何翻译 如果搜索的话, 搜这个会出来很多内容 yii cgridview template summary 好了,其他不说 ...
- [转自小兵的工具箱]C++ Builder 基础
1. C++ Builder 网上资源 C++ Builder 研究 http://www.ccrun.com/ C++ Builder 程序员 http://mybcb.diy.myri ...
- Java 迭代器理解
1.Iterator(迭代器) 作为一种设计模式,迭代器可以用于遍历一个对象,对于这个对象的底层结构不必去了解. java中的Iterator一般称为“轻量级”对象,创建它的代价是比较小的.这里笔者不 ...
- Java迭代器深入理解及使用
Iterator(迭代器) 作为一种设计模式,迭代器可以用于遍历一个对象,对于这个对象的底层结构开发人员不必去了解. java中的Iterator一般称为“轻量级”对象,创建它的代价是比较小的.这里笔 ...
- J1002.JavaFX简介
引言 2008年12月05日,SUN发布了JavaFX第一个正式版本,以期望Java在UI端能够更好地应用于开发富客户端的互联网应用(Rich Internet Cliet). 2011年发布的Jav ...
- Spring4 JDBC详解
Spring4 JDBC详解 在之前的Spring4 IOC详解 的文章中,并没有介绍使用外部属性的知识点.现在利用配置c3p0连接池的契机来一起学习.本章内容主要有两个部分:配置c3p0(重点)和 ...
- FOFA爬虫大法——API的简单利用
FOFA是一款网络空间搜索引擎,它通过进行网络空间测绘,帮助研究人员或者企业迅速进行网络资产匹配,例如进行漏洞影响范围分析.应用分布统计.应用流行度等. 何为API?如果你在百度百科上搜索,你会得到如 ...
- Java多线程之一
进程与线程 进程 进程是进程实体的运行过程,是系统进行资源分配和调度的一个独立单位,比如我们windows电脑上运行的一个程序就是一个进程.在传统进程中进程是资源分配和调度的一个基本单位,在后来引入线 ...
- 将应用代码由eclipse导入Android studio的方法NDK-Build和Cmake两种方法(以android_serialport_api为例)
网上翻了几百篇博客,看了半天,要不就是写的乱七八糟看不懂,要不就是隐藏了一些细节,要不就是实现不了,最后还是在Android官网上看明白了,而且说得有条有理,以后遇到不懂的一定要先翻官网. 参考资料: ...
随机推荐
- 【solr】Solr5.5.4单机部署
Solr5.5.4单机部署 Solr5和Solr4有很大区别,最为明显的就是Solr5已经可以独立部署,从Solr5开始,Solr已经不再以war包形式部署,Solr已经成为了一个独立的java服务端 ...
- IntelliJ IDEA 中如何查看一个类的所有继承关系(当前类的所有继承关系图)
IntelliJ IDEA 中如何查看一个类的所有继承关系(当前类的所有继承关系图) .embody{ padding:10px 10px 10px; margin:0 -20px; border-b ...
- 2019.8.13 NOIP模拟测试19 反思总结
最早写博客的一次∑ 听说等会儿还要考试[真就两天三考啊],教练催我们写博客… 大约是出题最友好的一次[虽然我还是炸了],并且数据也非常水…忽视第三题的锅的话的确可以这么说.但是T3数据出锅就是你的错了 ...
- BZOJ2529: [Poi2011]Sticks
2529: [Poi2011]Sticks Time Limit: 10 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 257 Solved: ...
- Laravel 批量替换某个字段
Likeword::offset(16854)->chunk(100, function ($word_list) { foreach ($word_list as $word) { $new ...
- Hdu 2389 二分匹配
题目链接 Rain on your Parade Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 655350/165535 K (Ja ...
- php thrift TServerSocket实现端口复用
<?php namespace Message\Controller; use Think\Controller; use Thrift\Exception\TException; use Th ...
- Android——内存管理基础
内存收集概念 内存垃圾收集器(garbage collector) 概念:自定内存管理. 功能:分配内存.保证所有被引用的对象还在内存中.可以释放在运行的代码中不再引用的对象的内存. 垃圾收集器避免了 ...
- Linux SSH远程链接 短时间内断开
Linux SSH远程链接 短时间内断开 操作系统:RedHat 7.5 问题描述: 在进行SSH链接后,时不时的就断开了 解决方案: 修改 /etc/ssh/sshd_config 文件,找到 Cl ...
- 抽象类 abstract class 接口
一.抽象类 1.没有具体的实例. 不可实例化,不能创建对象. 2.抽象类有构造器. 二.abstract 方法. 1.没有方法体. 子类必须重写抽象类的所有抽象方法,才能实例化,否则子类也为抽象类. ...