iOS 6/7 UISearchBar的背景色设置
2016-01-25 15:13
435 查看
在iOS7中,UISearchBar的子视图变成一个UIView,所以原来的方法不管用了,但是看了一下文档,在iOS7中新增了一个barTintColor的属性,我们可以设置barTintColor为clearColor
float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if ([ searchBar respondsToSelector : @selector (barTintColor)]) { float iosversion7_1 = 7.1 ; if(version >= iosversion7_1) { //iOS7.1 [[[[searchBar.subviews objectAtIndex : 0 ] subviews] objectAtIndex:0] removeFromSuperview]; [ searchBar setBackgroundColor:[ UIColor clearColor]]; } else { //iOS7.0 [ searchBar setBarTintColor:[UIColor clearColor]]; [ searchBar setBackgroundColor:[UIColor clearColor]]; } } else { //iOS7.0 以下 [[searchBar.subviews objectAtIndex:0] removeFromSuperview ]; [searchBar setBackgroundColor:[UIColor clearColor]]; }
相关文章推荐
- uiimagePickerViewController
- leetcode之Range Sum Query - Immutable
- 1. A "Getting Started" Guide for ROS and TurtleBot
- UIScrollView 代理方法
- 用storyboard显示不同屏幕的UI效果
- Map.values()/entrySet()/keySet() 无法序列化问题
- UIGraphicsBeginImageContext系列知识
- iOS开发之UIDocumentInteractionController
- DRUID连接池的使用
- sizeThatFits 和 sizeToFit区别
- ajax中的setRequestHeader设置请求头
- iOS身份证控制和手机号设置 和 十六进制的颜色转换为UIColor
- CUICatalog: Invalid asset name supplied:
- 使用系统UICollectionViewFlowLayout布局类
- java dev guide
- UITextView的placeholder属性
- UIImageView 的contentMode属性
- spark操作parquet文件
- UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte
- 第五篇 UICollectionView