You can add a view(e.g. blackMaskView) above mapView with:
self.mapview.insertSubview(blackMaskView, aboveSubview: self.mapview)
and then add a blur effect to blackMaskView as follows:
func createBlurView() {
// Blur Background
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.view.bounds
self.blackMaskView.addSubview(blurEffectView)
self.view.layoutIfNeeded()
}
Use blackMaskView.isHidden = true, to finally hide the blurred view.
Please mark the answer correct if you find it useful.