‘’‘’
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
//如果导航栏有背景色,也需要修改下
self.navigationController?.navigationBar.barTintColor = UIColor.clearColor()
self.navigationController?.navigationBar.translucent = true
for subview in self.view.subviews {
if subview.isKindOfClass(UIWebView) {
let webview = subview as! UIWebView
//webview的y轴起点默认为64
webview.scrollView.contentInset = UIEdgeInsets(top: -64, left: 0, bottom: 0, right: 0)
}
}
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = nil
self.navigationController?.navigationBar.translucent = false
}
‘’‘’