How to hide the navigation Bar in the first Viewcontroller iOS swift?
Solution:
If you want to hide the navigation bar in the first screen only then you must want to hide the navigation bar in the first screen and show the navigation bar in all the screens.You can add the below code in the first ViewController is the best solution.Otherwise no of lines will be increased.
Objective C:
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
If you want to hide the navigation bar in the first screen only then you must want to hide the navigation bar in the first screen and show the navigation bar in all the screens.You can add the below code in the first ViewController is the best solution.Otherwise no of lines will be increased.
Objective C:
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
Swift:
override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBar.isHidden = true
}
self.navigationController?.navigationBar.isHidden = true
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.navigationBar.isHidden = false
}
self.navigationController?.navigationBar.isHidden = false
}
Comments
Post a Comment