Created
June 27, 2023 18:14
-
-
Save sebjvidal/2f2b6500a6c59a7add2d77631d3511a8 to your computer and use it in GitHub Desktop.
Revisions
-
sebjvidal created this gist
Jun 27, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ // MARK: - SceneDelegate class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil) (navigationController.navigationBar as! NavigationBar).preferredHeight = 88 navigationController.setViewControllers([ViewController()], animated: false) guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) window.rootViewController = navigationController window.makeKeyAndVisible() self.window = window } } // MARK: - NavigationBar class NavigationBar: UINavigationBar { var preferredHeight: CGFloat = 44 override var frame: CGRect { get { return super.frame } set { var frame = newValue frame.size.height = preferredHeight super.frame = frame } } override func layoutSubviews() { super.layoutSubviews() frame = CGRect(x: frame.minX, y: frame.minY, width: frame.width, height: preferredHeight) } } // MARK: - ViewController class ViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) transitionCoordinator?.animate { _ in (self.navigationController?.navigationBar as? NavigationBar)?.preferredHeight = 88 } } } // MARK: - DetailViewController class DetailViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) transitionCoordinator?.animate { _ in (self.navigationController?.navigationBar as? NavigationBar)?.preferredHeight = 44 } } }