简体   繁体   English

UIVisualEffectView和UITableView

[英]UIVisualEffectView and UITableView

I've put a UITableView into a UIVisualEffectView to achieve vibrancy. 我已经将UITableView放入UIVisualEffectView中以实现活力。 Everything works fine except for the bounce feature. 除弹跳功能外,其他所有功能均正常运行。 The space where no cells are while scrolling gets drawn in some grey color instead of the blurred effect. 滚动时没有单元格的空间会以某种灰色绘制,而不是模糊效果。 I have tried to set all the background colours to clear but the blur still won't show. 我尝试将所有背景颜色设置为清除,但仍然无法显示模糊。 Is there any way to give the background the same effect as the rest of the table view? 有什么方法可以使背景与表格视图的其余部分具有相同的效果?

You can find the demo project here 您可以在此处找到演示项目

正常滚动

set Clear color of Table view, TableviewCell and ContainerView from Property. 从属性设置Table视图,TableviewCell和ContainerView的清除颜色。 if not Clear then put code in your view Controller. 如果不清除,则将代码放入视图控制器中。 also selection of cell none option. 还选择“无单元格”选项。

在此处输入图片说明

SWIFT 迅速

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    cell.backgroundColor = UIColor.clearColor()
} 

So I've found the answer. 所以我找到了答案。 Instead of making the background a clear color, you need to set a white color. 您无需将背景设置为清晰的颜色,而需要设置白色。

override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.backgroundColor = UIColor.whiteColor()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM