         }
     }
     
-    private func setSafeAreaInsets(_ insets: UIEdgeInsets) {
+    private func updateSafeAreaInsets() {
+        guard let insets = rootViewController?.view.safeAreaInsets else {
+            return
+        }
+        
+        let finalInsets = UIEdgeInsets(
+            top:    maskedEdges.contains(.top)    ? insets.top    : 0,
+            left:   maskedEdges.contains(.left)   ? insets.left   : 0,
+            bottom: maskedEdges.contains(.bottom) ? insets.bottom : 0,
+            right:  maskedEdges.contains(.right)  ? insets.right  : 0)
+        
         let safeViewFrame: CGRect = {
             if shouldShowBarsOnlyOniPhoneX && !isiPhoneX {
                 return bounds
             } else {
-                return bounds.insetBy(insets: insets)
+                return bounds.insetBy(insets: finalInsets)
             }
         }()
         

    
    // MARK:- Public variables
    
    /// The corner radius for the rounded view. It can be set to a custom value,
    /// or to use the standard value which sets the corner radius appropriately
    /// for the screen size

            return
        }
        
        updateSafeAreaInsets()
    }
    
    // MARK:- Private methods
