适配iOS7之—UITableView和UISearchBar(待续)
来源:互联网 发布:淘宝商业的竞争环境 编辑:程序博客网 时间:2024/05/02 00:07
iOS7中,如果用UITableViewStyleGrouped的话,里面的 cell会比原来的拉长了 ,这样做应该是为了统一和UITableViewStylePlain风格时cell的大小一致,所以改用UITableViewStylePlain后,就没问题了,而且在iOS7中,使用UITableViewStyleGrouped风格时,上面会出现 headView ,大概占了35个像素,使用 UITableViewStyleGrouped 风格的朋友们注意了,如下图为使用UITableViewStyleGrouped时的差异:
图1-1
还有就是iOS7下的UITableView增加了一个 UITableViewWrapperView 子视图,UITableViewCell变成了UITableViewWrapperView的子视图,而在iOS6中,UITableViewCell是UITableView的子视图。
用代码表现出来就是:
UITableView *tableView = (UITableView *)cell.superview.superview;
//in iOS7
UITableView *tableView = (UITableView *)cell.superview;
//in iOS6
如果之前定制cell的时候,用下面代码取tableView的需要做适配了。
UITableView *tableView = (UITableView *)
self
.superview;
还有就是现在可以直接设置 UITableView的背景颜色 了:
_loginTable.backgroundColor = [UIColor redColor];
另一个问题就是我使用 UISearchBar 的时候,Apple在iOS7中也做了调整。如下图:
图1-2
相信很多人在使用UISearchBar的时候,都比较喜欢上面的那种去了背景色的样子,在iOS6中我是使用下面这种方式去除背景色:
//for iOS6
for
(UIView *subview in
self
.search.subviews) {
if
([subview isKindOfClass:
NSClassFromString
(
@"UISearchBarBackground"
)]) {
[subview removeFromSuperview];
break
;
}
}
而今天突然发现,纳尼,在iOS7中,搜索框消失了,用小伙伴的方法看了一下,原来视图树改变了。如下图:
在iOS7中,UISearchBar的子视图变成一个UIView,所以原来的方法不管用了,但是看了一下文档,在iOS7中新增了一个barTintColor的属性,我们可以设置 barTintColor 为clearColor,便得到图1-2中的效果。
//for iOS 7
if
([
self
.search respondsToSelector:
@selector
(barTintColor)]) {
[
self
.search setBarTintColor:[UIColor clearColor]];
}
- 适配iOS7之—UITableView和UISearchBar(待续)
- 适配iOS7之—UITableView和UISearchBar
- 适配iOS7之—UITableView和UISearchBar
- 适配iOS7之—UITableView和UISearchBar
- 适配iOS7 — UISearchBar
- 自定义UISearchBar 适配IOS6和IOS7
- 自定义UISearchBar 适配IOS6和IOS7
- UITableView和UISearchBar在ios7和ios6之间的区别【转】
- UITableView和UISearchBar在ios7和ios6之间的区别【转】
- ios7上UISearchBar和UITableView下拉刷新的时候阴影解决
- UITableView之奇葩特性(未完待续)
- IOS-UITableView和UISearchBar示例
- ios7 UISearchBar
- UItableView和UISearchBar实现简单表格搜索
- IOS7学习之路二(处理ios6到ios7后UITableView的两个显示问题)
- UISearchBar和UITableView实现简单的模糊查询
- UITableView,UITableViewCell,UIPickerView,UISearchBar
- UITableView,UITableViewCell,UIPickerView,UISearchBar
- 用二叉树来理解树状数组
- Java简易绘图板
- 相遇在天 相守在人
- java自学之路-----JSP_基础语法
- 黑马程序员-----------android自学第一天总结
- 适配iOS7之—UITableView和UISearchBar(待续)
- 世上最心痛的距离
- POJ 1185炮兵阵地
- linux下安装配置ant
- iOS7适配,求iOS8文档
- 【招聘曝光】网上淘宝刷单兼职靠谱吗 刷钻兼职日结工资是真的吗
- Qt StyleSheet的使用
- hdu1754
- 苹果上传app