Skip to content

Instantly share code, notes, and snippets.

@konnnn
Last active February 15, 2021 18:38
Show Gist options
  • Save konnnn/7067b9d5033e64250b21ac53656a6d0d to your computer and use it in GitHub Desktop.
Save konnnn/7067b9d5033e64250b21ac53656a6d0d to your computer and use it in GitHub Desktop.
Clear Navigation Bar bottom shadow, set clear color and translucent true
//
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
setupAppearance()
}
fileprivate func setupAppearance() {
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: UIBarMetrics.default)
// remove shadow at the bottom
UINavigationBar.appearance().shadowImage = UIImage()
// set navbar to translucent
UINavigationBar.appearance().isTranslucent = true
// background color
UINavigationBar.appearance().backgroundColor = .clear
// configure font color, size and weight
UINavigationBar.appearance().titleTextAttributes = [
NSAttributedString.Key.foregroundColor: UIColor.black,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 25.0, weight: .black)
]
// optional: configure back button
UINavigationBar.appearance().backIndicatorImage = UIImage(systemName: "chevron.left.2")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(systemName: "chevron.left.2")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//
self.navigationItem.title = "Navigation Bar"
}
}
@konnnn
Copy link
Author

konnnn commented Feb 15, 2021

Снимок экрана 2021-02-15 в 22 37 39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment