ios - UITableView blurred overlay
问题描述
In my project I want to achieve a blurred background in a UITableView
.
So far I already set up the overlay like this:
let blurEffect = UIBlurEffect(style: .dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.view.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.tableView.insertSubview(blurEffectView, at: 0)
Now I got the problem that the blurred overlay is on top of my table cell. See given image. The order should be like this: UITableView
(which has a bg-color) - UIVisualEffectView
(blurred overlay) - UITableViewCell
How can I put the overlay between the table view and it's cell? Or is there even a better solution to this?
解决方案
Make your blurred view tableview's background view and it should look correct.
let blurEffect = UIBlurEffect(style: .dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.view.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.tableView.backgroundView = blurEffectView
推荐阅读
- android - 尝试将图像保存到外部存储时代码失败
- rust - 如何在 Rust 迭代期间获取然后修改 HashMap 的值?
- web - 用例中的 UML 角色
- javascript - 在 JavaScript 中将 plotly 导出为自包含的 html
- c# - OnTriggerEnter2D (Collider2D other) ... 访问多个外部脚本函数
- ajax - laravel 过滤器 ajax 和分页
- multithreading - delphi 是高 i/o 使用率的好模式
- c - SetConsoleCursorPosition : 使用时在控制台中获取黑色行
- python - Python 2.7 > 3.5 JSON 转储“不是字符串”
- shell - 如何在unix中读取特定列的文件集