UISearchbar设置相关总结
来源:互联网 发布:fenlog软件破解版 编辑:程序博客网 时间:2024/06/14 04:07
去掉输入框后面的背景框
突然有一天发现searcher.backgroundColor = [UIColor clearColor];不管用了,那么,,,,又是一顿在网上找,,
os系统升级到7.1后,原来在7.0下显示正常的UISearchbar现在又出现问题了。究其原因,是由于UISearchbar的subview又做修改了。
float version = [[[UIDevice currentDevice ] systemVersion ]floatValue ];
if ([ mySearchBar respondsToSelector : @selector (barTintColor)]) {
float iosversion7_1 = 7.1 ;
if (version >= iosversion7_1)
{
//iOS7.1
[[[[ mySearchBar . subviews objectAtIndex : 0 ] subviews ] objectAtIndex :0 ] removeFromSuperview ];
[ mySearchBar setBackgroundColor :[ UIColor clearColor ]];
}
else
{
//iOS7.0
[ mySearchBar setBarTintColor :[ UIColor clearColor ]];
[ mySearchBar setBackgroundColor :[ UIColor clearColor ]];
}
}
else
{
//iOS7.0 以下
[[ mySearchBar . subviews objectAtIndex : 0 ] removeFromSuperview ];
[ mySearchBar setBackgroundColor :[ UIColor clearColor ]];
}
修改searchBar的输入框背景色
7.0以前:
for (UIView *subView in _searchBar.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) {
subView.backgroundColor = RGBColor(19,115, 209);
}
}
7.0及以后:
// 经测试, 需要设置barTintColor后,才能拿到UISearchBarTextField对象
_searchBar.barTintColor =RGBColor(23,130, 235);
[[_searchBar.subviews[0]subviews] lastObject].backgroundColor =RGBColor(19,115, 209);
修改输入框的placeholder颜色和输入颜色
//获取searchBar里面的输入框有两种方法
// UITextField *searchTextField = [[_searchBar.subviews[0] subviews] lastObject];
UITextField *searchTextField = [_searchBarvalueForKey:@"_searchField"];
searchTextField.backgroundColor = RGBColor(19, 115, 209);
[searchTextField setValue:[UIColorwhiteColor]forKeyPath:@"_placeholderLabel.textColor"];
searchTextField.textColor = [UIColorwhiteColor];
- UISearchbar设置相关总结
- UISearchBar相关
- UISearchBar相关
- UISearchBar属性相关
- UISearchBar 的相关属性
- UISearchBar属性相关
- 设置UISearchBar的背景图片
- UISearchBar设置透明背景
- UISearchBar常见设置
- UISearchBar 背景 边框设置
- UISearchBar光标偏移设置
- UiSearchBar圆角设置
- eclipse 相关设置总结
- ios(总结)UISearchBar
- 关于 UISearchBar 的总结
- UISearchBar使用总结
- 设置UISearchBar并修改背景
- 在NavigtionBar上设置 UISearchBar
- 移动软件原型设计工具
- 分辨率drawable-hdpi/mdpi/ldpi
- const在C与C++中的区别
- HTML基础学习资料
- IOS跳转界面方法(可以根据参数动态跳转不同页面)
- UISearchbar设置相关总结
- 编程入门思维导图
- NYOJ 题目12 喷水装置(二) 最小区间覆盖问题
- 思念到极致时什么感觉?(1)
- VS2013中编译项目在静态库中使用MFC出现错误的解决方法
- 导航条的制作
- CSAPP Tiny web 服务器源码分析及搭建运行
- LeetCode OJ - Merge Two Sorted Lists
- Oracle中TO_DATE TO_CHAR格式