         }
     }
 
-    override func layoutSubviews() {
-        super.layoutSubviews()
-        self.updateMask()
-    }
-
     fileprivate lazy var maskLayer: CAShapeLayer = {
         let mask = CAShapeLayer()
         mask.fillRule = kCAFillRuleEvenOdd
         return mask
     }()
 
+    fileprivate lazy var theMaskView: UIView = {
+        let maskView = UIView()
+        maskView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+        maskView.isUserInteractionEnabled = false
+        maskView.backgroundColor = UIColor.black
+        return maskView
+    }()
+
     fileprivate func updateMask() {
-        if self.layer.mask == nil {
-            self.layer.mask = self.maskLayer
-        }
 
+        theMaskView.frame = self.bounds
+        theMaskView.layer.mask = maskLayer
         let maskRect = self.maskRect ?? self.bounds
         let clipPath = self.maskPath?.path(in: maskRect) ?? UIBezierPath(ovalIn: maskRect)
 


class MaskView: UIVisualEffectView {

    var maskPath: Mask? {
        didSet {
            self.updateMask()

        path.addRect(self.bounds)
        path.addPath(clipPath.cgPath)

        maskLayer.path = path
        self.mask = theMaskView
    }
}
