2016-09-01 6 views
0

Real time blur effect for Navigation BarBlur Effekt auf Navigationsleiste, während einen Tableviewcontroller unter Verwendung von

die Lösung in dem oben erwähnten Beitrag ausprobiert,

AppDelegate.swift

// Sets background to a blank/empty image 
     UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default) 
     // Sets shadow (line below the bar) to a blank image 
     UINavigationBar.appearance().shadowImage = UIImage() 
     // Sets the translucent background color 
     UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0) 
     // Set translucent. (Default value is already true, so this can be removed if desired.) 
     UINavigationBar.appearance().translucent = true 

RootVC.swift

func addBlurEffect() { 
     // Add blur view 
     let bounds = self.navigationController?.navigationBar.bounds as CGRect! 
     let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) 
     visualEffectView.frame = bounds 
     visualEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] 
     self.navigationController?.navigationBar.addSubview(visualEffectView) 
     self.navigationController?.navigationBar.sendSubviewToBack(visualEffectView) 

     // Here you can add visual effects to any UIView control. 
     // Replace custom view with navigation bar in above code to add effects to custom view. 
    } 

In viewDidLoad verwendet self.addBlurEffect.

Problem, ist die Statusleiste immer noch nicht verwischt, und der Unschärfe-Effekt ist nur auf RootVC.swift beschränkt.

Wie kann ich es auf alle Sub-VCs erweitern?

Antwort

0

gibt dieses einen Schuss:

bounds.offsetInPlace(dx: 0.0, dy: -20.0) 
bounds.size.height = bounds.height + 20.0 

Found it here

Verwandte Themen