ios - 为什么设置UITableView的backgroundView在最上层遮挡内容?
PHPz
PHPz 2017-04-17 17:49:57
0
2
333

现用代码:

let img = UIImage(contentsOfFile: NSBundle.mainBundle().pathForResource("logo", ofType: "png")!)
        
let bgView = UIImageView()
bgView.image = img
bgView.contentMode = .ScaleAspectFill
        
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame = bgView.bounds
bgView.addSubview(blurView)
        
self.tableView.backgroundView = bgView

效果:

PHPz
PHPz

学习是最好的投资!

Antworte allen(2)
小葫芦

backgroundView 应该是固定在最底层,无法更改
你可以使用其他方法来实现该效果,如果图片可以滚动直接添加到 tableView 上,如果需要固定可以添加到 tabBar 或者 navigationBar,使用 insertSubview: 系列方法来插入可控制在父视图中的显示层级

阿神

添加这部分代码的逻辑是不是放到cell出现以后了?

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage