我正在创建一个带有中间透明矩形的模糊视图叠加层。到目前为止,我的代码实现了相反的效果,即在中间有一个模糊剪裁而成的透明视图。
我已经从以下帖子中调整了我的步骤,如果有人能指点我正确的方向,我将不胜感激。
Swift mask of circle layer over UIView
CALayer with transparent hole in it
let blurView = UIVisualEffectView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height))
blurView.effect = UIBlurEffect(style: UIBlurEffectStyle.dark)
let scanLayer = CAShapeLayer()
scanLayer.path = CGPath(rect: scanRect, transform: nil)
view.addSubview(blurView)
blurView.layer.addSublayer(scanLayer)
blurView.layer.mask = scanLayer