[英]Blur effect on navigation bar while using a tableviewcontroller
Real time blur effect for Navigation Bar 导航栏的实时模糊效果
Tried the solution mentioned in the above post, 试过上面帖子中提到的解决方案,
AppDelegate.swift 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 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
used self.addBlurEffect
. 在
viewDidLoad
使用了self.addBlurEffect
。
Problem, is status bar is still not blurred, and the blur effect is restricted only to RootVC.swift. 问题,状态栏仍然没有模糊,模糊效果仅限于RootVC.swift。
How can I extend it to all sub VCs? 如何将其扩展到所有子VC?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.