private var shadowImg = UIImageView()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 11, *) {
navigationController?.navigationBar.shadowImage = UIImage()
}else{
if let subviews = self.navigationController?.navigationBar.subviews {
for shadow in subviews {
for sha in shadow.subviews {
if sha.isKind(of: UIImageView.self) && sha.bounds.size.height < 1 {
self.shadowImg = sha as! UIImageView
}
}
}
self.shadowImg.isHidden = true
}
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.searchView.textField.resignFirstResponder()
if #available(iOS 11, *) {
navigationController?.navigationBar.shadowImage = nil
navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
}else{
self.shadowImg.isHidden = false
}
}
网友评论