search

Home  >  Q&A  >  body text

ios - 为什么设置UITableView的backgroundView在最上层遮挡内容?

现用代码:

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

效果:

PHPzPHPz2889 days ago335

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:51:57

    BackgroundView should be fixed at the bottom layer and cannot be changed
    You can use other methods to achieve this effect. If the image can be scrolled, add it directly to the tableView. If it needs to be fixed, it can be added to the tabBar or navigationBar. Use the insertSubview: series method to insert the Control the display level in the parent view

    reply
    1
  • 阿神

    阿神2017-04-17 17:51:57

    Is the logic of adding this part of code placed after the cell appears?

    reply
    0
  • Cancelreply