feat:record and resume previous state of NavigationBar for iOS

This commit is contained in:
pengfei.zhou 2019-11-25 15:45:14 +08:00
parent 7bef2fbd68
commit 7e0561cbb6

View File

@ -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;