Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Created August 2, 2021 21:22
Show Gist options
  • Save alexpaul/57a3bad2c665856247a15645fdfe9b44 to your computer and use it in GitHub Desktop.
Save alexpaul/57a3bad2c665856247a15645fdfe9b44 to your computer and use it in GitHub Desktop.
Hide navigationbar border
extension UINavigationController {
func hideHairline() {
if let hairline = findHairlineImageViewUnder(navigationBar) {
hairline.isHidden = true
}
}
func restoreHairline() {
if let hairline = findHairlineImageViewUnder(navigationBar) {
hairline.isHidden = false
}
}
func findHairlineImageViewUnder(_ view: UIView) -> UIImageView? {
if view is UIImageView && view.bounds.size.height <= 1.0 {
return view as? UIImageView
}
for subview in view.subviews {
if let imageView = self.findHairlineImageViewUnder(subview) {
return imageView
}
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment