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官网上看明白了,而且说得有条有理,以后遇到不懂的一定要先翻官网. 参考资料: ...
随机推荐
- HTML5属性
HTML5同时增加和废除了很多属性.下面介绍一些常用的属性. 1.表单属性 为input(type=text).select.textarea与button元素新增了autofocus属性.(它以指定 ...
- 序列化form表单
// 序列化JSON字符串 $.fn.serializeObject = function () { let o = {}; let a = this.serializeArray(); $.each ...
- leetcode 76 dp& 强连通分量&并查集经典操作
800. Similar RGB Color class Solution { int getn(int k){ return (k+8)/17; } string strd(int k){ char ...
- oracle-约束-序列
概要图 一 约束 --问题:往表中插入数据的时候,可能出现一些问题,比如:重复插入数据,内容不对(性别) --如何保证数据库表中数据的完整性和一致性呢? 约束是强加在表上的规则或条件,确保数据库满足业 ...
- 洛谷P1062 数列 [2017年6月计划 数论03]
P1062 数列 题目描述 给定一个正整数k(3≤k≤15),把所有k的方幂及所有有限个互不相等的k的方幂之和构成一个递增的序列,例如,当k=3时,这个序列是: 1,3,4,9,10,12,13,… ...
- 牛人也得看的CSS常识
1.不要使用过小的图片做背景平铺.这就是为何很多人都不用 1px 的原因,这才知晓. 宽高 1px 的图片平铺出一个宽高 200px 的区域,需要 200*200=40, 000 次,占用资源. 2. ...
- Linux 7.X 网络配置
Linux 7.X 网络配置 环境: 笔记本中安装了虚拟机,在虚拟机中安装了Redhat 7.4版本的操作系统,现配置该操作系统网络.(IP.网关等) 相关指令如下: # nmcli connecti ...
- PHP学习(语言结构语句)
switch case语句 for循环语句: foreach循环语句 常用于遍历数组,一般有两种使用方式:不取下标.取下标. (1)只取值,不取下标 <?php foreach (数组 as 值 ...
- LeedCode --- Best Time to Buy and Sell Stock
题目链接 题意: find the maximum positive difference between the price on the ith day and the jth day 附上代码: ...
- php 如何生成静态页
PHP文件名:dome.php <?php $string = 1; ob_start(); @readfile("templets/list.html"); $text = ...