“反弹区域"中的浅灰色背景;一个 UITableView [英] Light gray background in "bounce area" of a UITableView

查看:15
本文介绍了“反弹区域"中的浅灰色背景;一个 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple 的 iPhone 应用程序(例如 Music 和 Contants)在 UITableView 中使用搜索栏.当您向下滚动以使搜索栏向下移动时,滚动视图内容上方的空白区域具有浅灰色背景色(参见屏幕截图).

Apple's iPhone apps such as Music and Contants use a search bar in a UITableView. When you scroll down so that the search bar moves down, the empty space above the scroll view's contents has a light gray background color (see screenshot).

(请注意,搜索栏的顶部有一条稍暗的边缘线.默认的 UISearchBar 不存在,但子类化应该会解决这个问题.)

(Notice that the search bar has a slightly darker edge line at its top. This is not there for the default UISearchBar, but subclassing should take care of that.)

我尝试设置 UITableView 的背景颜色,但这也会影响行.有谁知道如何达到这个效果?我是否必须重写实现 drawRect: 还是有内置方法?

I tried setting the background color of the UITableView, but that affects the rows as well. Does anyone know how to achieve this effect? Am I going to have to override implement drawRect: or is there a built in way?

推荐答案

从 iOS 7 开始,您可以通过更改 tableview 背景视图来解决这个问题.

As of iOS 7, you can tinker this by changing the tableview background view.

[self.tableView setBackgroundView:view];

使视图的背景颜色与父视图颜色相同.

make the view's background colour the same as your parent view colour.

这篇关于“反弹区域"中的浅灰色背景;一个 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆