From 7e0561cbb68754d08a803b32b727a8144980a8c9 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Mon, 25 Nov 2019 15:45:14 +0800 Subject: [PATCH] feat:record and resume previous state of NavigationBar for iOS --- iOS/Pod/Classes/DoricViewController.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/iOS/Pod/Classes/DoricViewController.m b/iOS/Pod/Classes/DoricViewController.m index 637b5b62..b20bb3c8 100644 --- a/iOS/Pod/Classes/DoricViewController.m +++ b/iOS/Pod/Classes/DoricViewController.m @@ -27,6 +27,8 @@ @interface DoricViewController () @property(nonatomic, strong) DoricPanel *doricPanel; +@property(nonatomic) BOOL navBarHidden; +@property(nonatomic, strong) UIImage *navBarImage; @end @implementation DoricViewController @@ -54,6 +56,22 @@ - (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias { return self; } +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + self.navBarHidden = self.navigationController.navigationBarHidden; + self.navBarImage = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + if (self.navigationController.navigationBarHidden != self.navBarHidden) { + [self.navigationController setNavigationBarHidden:self.navBarHidden]; + } + if (self.navBarImage != [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]) { + [self.navigationController.navigationBar setBackgroundImage:self.navBarImage forBarMetrics:UIBarMetricsDefault]; + } +} + - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; self.doricPanel.view.width = self.view.width;