亲测,项目中正在使用
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if self.navigationController != nil {
let navBarHairlineImageView = self.findHairlineImageViewUnder(sView: self.navigationController!.navigationBar)
navBarHairlineImageView.isHidden = true
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if self.navigationController != nil {
let navBarHairlineImageView = self.findHairlineImageViewUnder(sView: self.navigationController!.navigationBar)
navBarHairlineImageView.isHidden = false
}
}
func findHairlineImageViewUnder(sView: UIView) ->UIImageView {
if sView.isKind(of: UIImageView.self) && sView.bounds.height <= 1 {
return sView as! UIImageView
}
for sview in sView.subviews {
let imgs = self.findHairlineImageViewUnder(sView: sview)
if imgs.isKind(of: UIImageView.self) && imgs.bounds.height <= 1 {
return imgs
}
}
return UIImageView.init()
}
网友评论